<?php

/** Controller Trang home ***/
class home extends Controller {
	
	private $view_home;
	private $header;
	private $footer;
	private $number_get = 10;
	private $number_get_news = 20;
	private $number_get_contact = 6;
    private $number_statistic = 6;

	public $cates;
	public $events;
	public $jobs;
	public $seeker;
	public $top_news;
	public $questions;
	public $paging;
	public $msg;
	public $news_focus;
	public $weblinks;
	public $quatang;
	public $data_footer;
    //v3
    public $video;
    public $images;
    public $group;
    public $discovery;
    public $tags;
    //------v4 --/   
    public $numdiscovery = 5;
    public $numtopnews = 6;
    public $numgroup = 6;
    public $idear;
    public $onlydesigns;
    public $catecontact;
    private $timecate = 10;
    
     
    /** Ham khoi tao ***/	 
	function home(){
		parent::Controller();
		session_start();
		$this->load->model('home_model');
        $this->load->model('poll_model');
		$this->load->helper('replacevn_helper');
		$this->load->helper('main_helper');
        $this->load->helper('user_helper');
        $this->load->helper('mail_helper');

		$this->load->library('MY_Paginationhome');
		$this->config->load('home');//sua dung bien constants cho file home

        //main footer 1
        $this->data_footer = $this->home_model->get_footer(1);
        //menu tags
        $this->tags = $this->home_model->get_footer(2);
        // du an tim thiet ke
        $this->cate_duan = $this->home_model->getCate(8);
        //dich vu
        $this->cate_dv = $this->home_model->getCate(SERVICE_ABUOT);
        //contact category thi thiet ke
        $this->cate_tests = $this->home_model->getCate(SERVICE_TEST);
        
        //contact category new
        $this->cate_new = $this->home_model->getCate(SERVICE_NEWS);
        //contact category danh ba
        $this->catecontact = $this->home_model->get_cate_contact();

        $this->header = 'header';
		$this->footer = 'footer';
		$this->view_home = 'home';

        /** online visit **/
        $this->home_model->updateHit();
      // $this->output->enable_profiler();
	}

	/**
	 * @Desc Trang chu
	 */
	function index()
	{
        $this->output->cache($this->timecate);
        //ivents
        $this->events = $this->home_model->list_event(0 , 3);
        //tin doc nhieu right
        $this->top_news = $this->home_model->top_news(0,$this->numtopnews*3);
        //degins only right
        $this->onlydesigns = get_only_designs();
        //tieu diem
        $this->discovery = $this->home_model->list_news_discover('tieu-diem' , 0 , $this->numdiscovery*3);
        //tuyet dinh video
        $this->video = $this->home_model->list_news_cate('video',0,3);
        //tuyet dinh photo
        $this->images = $this->home_model->list_news_cate('nhiep-anh',0,3);
        //category kho y tuong
        $this->cate_idea = $this->home_model->getCateIdea();
        //noi dung
        $service_id = 1;
        $this->data['data'] = get_home_news($service_id);
        
        $this->data['cate_code'] = '';

        $this->data['service_id'] = $service_id;
       
        $this->data['home'] = 1;

        $this->data['title'] = 'Tin tức ngành thiết kế, quảng cáo và nghệ thuật  - www.designs.vn';
        $this->data['description'] = 'Danh bạ thiết kế, Cuộc thi thiết kế, Giải thưởng thiết kế, Việc làm thiết kế, Các sự kiện, Kiến trúc, Nội thất, Đồ họa, Quảng cáo, Hội họa, Nhiếp ảnh, Điện ảnh, Thời trang, Thiết kế sản phẩm.';
        $this->data['keywords']    = 'Noithat: Thietkenoithat, Thietke, tubep, Noithat, phong ngu, Thiet ke kien truc, Noithat, vanphong, Thietke, kientruc, Thietke nha o, Thietke, khachsan, Thietke nhahang, Quanly duan, Tu van, Nha thau, Sofa, Chieu sang, Den chum,Thiet ke quang cao
                                      Thiet ke do hoa, Thiet le logo, Thiet ke thuong hieu, Thiet ke bao bi, Thiet ke slogan, Thiet ke in an, Thiet ke poster, Nha in, Quang cao, Truyen thong, Su kien, Media, Truyen hinh, Bao chi, Vat lieu xay dung
                                      Vat lieu noi that, Cua hang noi that, Thiet bi ve sinh, Thiet bi nha bep, Thu cong my nghe, Dao tao thiet ke, Studio, Nguoi mau, Nghe si,Hoa si, Thoi trang, Nghe thuat, Danh ba, Danh ba thiet ke
                                      Danh ba quang cao, Cuoc thi, Cuoc thi thiet ke, Cac cuoc thi, Giai thuong thiet ke, Tuyen dung, Viec lam thiet ke, Tuyen Kien truc su, Tuyen Designer, Nhan vien thiet ke, Thiet ke san pham, Tao dang cong nghiep, Thiet ke thoi trang';

        $this->load->view($this->header ,$this->data );
        $this->load->view('left_home',$this->data );
        $this->load->view($this->view_home,$this->data );
        $this->load->view('right_home',$this->data );
        $this->load->view($this->footer,$this->data );
	}
    //trang dich vu,don bai
    function simpnews($closure = -1)
	{
		$detail = $this->home_model->simplenews($closure);
		if($detail)
		{
			$this->data['title'] = $detail['title'];
			$this->data['description'] = $detail['extract'];
			$this->data['keywords'] = $detail['extract'];
			$this->data['item'] = $detail;
			$this->cates = get_menu(SERVICE_NEWS);
			$this->data['cate_code'] = $detail['cate_code'];
			$this->data['service_id'] = SERVICE_NEWS;
			$this->load->view($this->header,$this->data);
			$this->load->view('cate_single',$this->data);
			$this->load->view($this->footer,$this->data);
		}
        else
        {
            $this->data['service_id'] = SERVICE_NEWS;
            $this->cates = get_menu(SERVICE_NEWS);
            $this->load->view($this->header,$this->data);
            $this->load->view('cate_single_update',$this->data);
            $this->load->view($this->footer,$this->data);
            //else redirect();
        }
	}
    /**
     * danh sach tin,hien thi theo category
     * thi thiet ke
     * tin tuc
     * */
	function cate_news($service_id=0 , $cate = 0, $page = 1,$id=0)
	{
	   // $this->output->cache($this->timecate);
        $this->events = $this->home_model->list_event(0 , 3);
		
        //category kho y tuong
        $this->cate_idea = $this->home_model->getCateIdea();
        $this->top_news = $this->home_model->top_news(0,$this->numtopnews*3);
		//$this->news_focus = $this->home_model->get_news_focus(0,9,1);
		$this->quatang = $this->home_model->get_quatang();
        // v3
        $this->video = $this->home_model->list_news_cate('video',0,3);
        $this->images = $this->home_model->list_news_cate('nhiep-anh',0,3);
        $this->discovery = $this->home_model->list_news_discover('tieu-diem' , 0 , $this->numdiscovery*3);
        //chuyen de
        //$this->group = $this->home_model->list_group_home(0 ,$this->numgroup*3);
        /*---------------V4 --------------------*/
        //$this->idear = get_idears(15);
        $this->onlydesigns = get_only_designs();

        $dcate = $this->home_model->detail_cate_closure($cate);
        //echo '<pre>'; var_dump($dcate); echo '</pre>';die;
		$prefix = '';
		switch ($service_id)
		{
			case SERVICE_NEWS: $prefix = 'tin-tuc/';
			break;
			case SERVICE_TEST: $prefix = '';
			break;
		}
		$start = ((int)$page - 1)*$this->number_get_news;
		$start = $start > 0 ? $start : 0;
		$cate = mysql_escape_string($cate);
		$service_id = (int)$service_id;
        $this->data['cate_news'] = $this->home_model->getNewByCate($id,$cate , 0 , 8);
        $this->data['newsByCate'] = $this->home_model->list_news($cate , $start , $this->number_get_news);
        $data = $this->home_model->list_news($cate , $start , $this->number_get_news);

		$config['base_url'] = base_url().$prefix.$cate.'_trang-';
		$config['total_rows'] = $data['total'];
		$config['per_page'] = $this->number_get_news;
		$config['key'] = '.html';
		$config['cur_page'] = $start;
		$config['num_links'] = 5;
		$config['first_link'] = '';
		$config['last_link'] = '';
		$config['next_link'] = '>>';
		$config['prev_link'] = '<<';
		$config['cur_tag_open'] = '<li><a id="current">';
		$config['cur_tag_close'] = '</a></li>';

		$this->my_paginationhome->initialize($config);

		$this->data['paging'] = $this->my_paginationhome->create_links();

        $this->data['items'] = $data['result'];
		$this->data['tops'] = $this->home_model->top_news(0 , 15 , 'date');
		$this->data['service_id'] = $service_id;
        //serviece_id = 1
        //ten cate url
		$this->data['cate_code'] = $cate;
		//cate co ca cate con
        $this->cates = get_menu(SERVICE_NEWS);
        //echo $this->db->last_query();die;


    	$this->data['title'] = (isset($dcate['name']) ? $dcate['name'] : 'Tin tức ngành thiết kế, quảng cáo và nghệ thuật').'  - www.designs.vn';
		$this->data['description']    = 'Danh bạ thiết kế, Cuộc thi thiết kế, Giải thưởng thiết kế, Việc làm thiết kế, Các sự kiện, Kiến trúc, Nội thất, Đồ họa, Quảng cáo, Hội họa, Nhiếp ảnh, Điện ảnh, Thời trang, Thiết kế sản phẩm.';
		$this->data['keywords']       = 'Noithat: Thietkenoithat, Thietke, tubep, Noithat, phong ngu, Thiet ke kien truc, Noithat, vanphong, Thietke, kientruc, Thietke nha o, Thietke, khachsan, Thietke nhahang, Quanly duan, Tu van, Nha thau, Sofa, Chieu sang, Den chum,Thiet ke quang cao
                                        Thiet ke do hoa, Thiet le logo, Thiet ke thuong hieu, Thiet ke bao bi, Thiet ke slogan, Thiet ke in an, Thiet ke poster, Nha in, Quang cao, Truyen thong, Su kien, Media, Truyen hinh, Bao chi, Vat lieu xay dung
                                        Vat lieu noi that, Cua hang noi that, Thiet bi ve sinh, Thiet bi nha bep, Thu cong my nghe, Dao tao thiet ke, Studio, Nguoi mau, Nghe si,Hoa si, Thoi trang, Nghe thuat, Danh ba, Danh ba thiet ke
                                        Danh ba quang cao, Cuoc thi, Cuoc thi thiet ke, Cac cuoc thi, Giai thuong thiet ke, Tuyen dung, Viec lam thiet ke, Tuyen Kien truc su, Tuyen Designer, Nhan vien thiet ke, Thiet ke san pham, Tao dang cong nghiep, Thiet ke thoi trang';

        //echo '<pre>'; var_dump($this->data); echo '</pre>';die;
		$this->load->view($this->header,$this->data);
        $this->load->view('left_home',$this->data);
		$this->load->view('cate_muti',$this->data);
        $this->load->view('right_home',$this->data);
		$this->load->view($this->footer,$this->data);
	}

	//hien thi cua mot mot tin tuc
    //hien thi tin tuc theo id

	function detail_new($sevice_id=0 , $id =0)
	{
	    $id = (int)$id;
	    $this->home_model->add_view($id);
	    //$this->output->cache($this->timecate);
        $this->cate_idea = $this->home_model->getCateIdea();
	    $this->events = $this->home_model->list_event(0 , 3);
		//$this->jobs = $this->home_model->list_new_job(JOB_TYPE_JOB,0,8);
		$this->top_news = $this->home_model->top_news(0,$this->numtopnews*3);
		//$this->quatang = $this->home_model->get_quatang();
        // v3
        $this->video = $this->home_model->list_news_cate('video',0,3);
        $this->images = $this->home_model->list_news_cate('nhiep-anh',0,3);
        $this->discovery = $this->home_model->list_news_discover('tieu-diem' , 0 , $this->numdiscovery*3);
        //chuyen de
        //$this->group = $this->home_model->list_group_home(0 ,$this->numgroup*3);
        /*---------------V4 --------------------*/
        //$this->idear = get_idears(15);
        $this->onlydesigns = get_only_designs();
        //show theo id bang new
		$detail = $this->home_model->detail_news($id);
		if($detail)
		{
            $this->data['id'] = $detail['id'];
            //echo '<pre>'; var_dump($this->data['id']); echo '</pre>';die;
			$this->data['title'] = $detail['title'];
			$this->data['description'] = $detail['extract'];
			$this->data['keywords'] = $detail['extract'];
            $this->data['item'] = $detail;
            //echo '<pre>'; var_dump($this->data['item']); echo '</pre>';die;
			$this->cates = get_menu((($sevice_id == SERVICE_EVENT || $sevice_id == SERVICE_TEST) ? SERVICE_NEWS : $sevice_id));
			$cate=$this->data['cate_code'] = $detail['cate_closure'] ;
            $cate_code = explode("_",$cate);
			$this->data['concern'] = $this->home_model->get_news_tags($cate_code[0], $detail['tag'],$detail['id']);
			$this->data['comment'] = $this->home_model->get_comments($detail['id']);

            //3 tin khac trong cung mot chuyen muc
            $this->data['others'] = $this->home_model->get_news_orther(@$cate_code[0],$detail['id'],$detail['date']);
            //$this->data['back'] = $this->home_model->get_news_back($detail['cate_code'],$detail['id'],$detail['date']);
			$this->data['service_id'] = $sevice_id;
            $this->data['group'] = list_group_news($id);
            // $this->data['poll'] = $this->poll_model->get_cate_poll(4);
            //tin moi nhat
            $this->data['tops'] = $this->home_model->top_news(0 , 15 , 'date');
            //tin cung danh muc
            $this->data['cate_news'] = $this->home_model->getNewByCate($id,@$cate_code[0] , 0 , 8);
			$this->load->view($this->header,$this->data);
			$this->load->view('left_home',$this->data);
            $this->load->view('detail',$this->data);
            $this->load->view('right_home',$this->data);
			$this->load->view($this->footer,$this->data);
			
		}
		else redirect();
	}

    /**
     * @param int $page
     * @param int $service_id
     * @param int $id trang tong du an
     */
    //du an
    function du_an($page = 1, $service_id = 0,$id=0)
    {
        //noi dung
        
       // redirect(base_url().'moi-gioi-thiet-ke.html');
        $service_id = 1;
        $this->data['cates_da'] = $this->home_model->getCate(8);
        $this->data['cities'] = $this->home_model->get_city();
        $this->data['service_id'] = $service_id;
       // $this->data['data'] = get_home_news($service_id);

        $numberget = 5;
        $start = ((int)$page - 1)*$numberget;
        $start = $start > 0 ? $start : 0;
        $this->data['projects'] = $this->home_model->getAllProject($start , $numberget);
        $config['base_url'] = base_url().'du-an_trang-';
        $config['total_rows'] = $this->home_model->countRows();
        $config['per_page'] = $numberget;
        $config['key'] = '.html';
        $config['cur_page'] = $start;
        $config['num_links'] = 5;
        $config['first_link'] = '';
        $config['last_link'] = '';
        $config['next_link'] = '>>';
        $config['prev_link'] = '<<';
        $config['cur_tag_open'] = '<li><a id="current">';
        $config['cur_tag_close'] = '</a></li>';

        $this->my_paginationhome->initialize($config);

        $this->data['paging'] = $this->my_paginationhome->create_links();

        $this->load->view('header',$this->data);
        $this->load->view('left_duan',$this->data);
        $this->load->view('right_duan',$this->data);
        $this->load->view($this->footer,$this->data);
    }
    //chi tiet du an
    function detail_da($id=0,$sevice_id = 0 )
    {
        //add nha thau
       // redirect(base_url().'moi-gioi-thiet-ke.html');
        $data = array();
        if(isset( $_POST['submit']))
        {
            $data['id_da'] = $id;
            $data['name'] = htmlspecialchars(trim($_POST['name']));
            $data['chuyen_mon']  = $_POST['chuyenmon'];
            $data['cities']  = $_POST['cities'];
            $data['phone']  = $_POST['phone'];
            $data['email']  = $_POST['email'];
            $data['link_contact']  = $_POST['link'];
            $data['status']  = 0;
            $data['date']  = time();
            $data['web']  = $_POST['web'];

            if(!is_dir('public/media/media/file/'.date('m'))) mkdir('public/media/media/file/'.date('m'),0777);
            if(trim($_FILES["hoso1"]['name'])!= ""){
                $config['upload_path'] = 'public/media/media/file/'.date('m');
                $config['allowed_types'] = 'gif|jpg|png|bmp|doc|pdf|zip';
                $config['max_size']	= '20480';
                $this->load->library('upload', $config);
                if ($this->upload->do_upload('hoso1')){
                    $upload_data = $this->upload->data();
                    $sourcefile  = $config['upload_path'].'/'.$upload_data['file_name'];
                    $data['hoso1'] = base_url().$sourcefile;
                }else $this->msg[] =  $this->upload->display_errors();
            }
            $this->load->library('image_lib');
            if(trim($_FILES["hoso2"]['name'])!= ""){
                $config['upload_path'] = 'public/media/media/file/'.date('m');
                $config['allowed_types'] = 'gif|jpg|png|bmp|doc|pdf|zip';
                $config['max_size']	= '20480';
                $this->load->library('upload', $config);
                if ($this->upload->do_upload('hoso2')){
                    $upload_data = $this->upload->data();
                    $sourcefile2  = $config['upload_path'].'/'.$upload_data['file_name'];
                    $data['hoso2'] =  base_url().$sourcefile2;
                }else $this->msg[] =  $this->upload->display_errors();
            }
            $this->load->library('image_lib');
            if(trim($_FILES["hoso3"]['name'])!= ""){
                $config['upload_path'] = 'public/media/media/file/'.date('m');
                $config['allowed_types'] = 'gif|jpg|png|bmp|doc|pdf|zip';
                $config['max_size']	= '20480';
                $this->load->library('upload', $config);
                if ($this->upload->do_upload('hoso3')){
                    $upload_data = $this->upload->data();
                    $sourcefile3  = $config['upload_path'].'/'.$upload_data['file_name'];
                    $data['hoso3'] =  base_url().$sourcefile3;
                }else $this->msg[] =  $this->upload->display_errors();
            }

            //$id_vip = $this->home_model->addUserVip($data);
            //add thong tin vào email marketing
            $emails = $this->home_model->getAllMail($data['email']);
             if(!$emails){
                $data_email = array(
                    'ten_dv'=> $data['name'],
                    'linhvuc' =>  $data['chuyen_mon'],
                    'phone' => $data['phone'],
                    'email'=>$data['email'],
                    'cities'=>  $data['cities'],
                    'phan_loai' => 'Đã từng dự thầu',
                    'group'=>1,
                    'website'=> $data['web'],
                    'status'=> 0,
                    'date' => time()
                );
                //$this->home_model->addEmailMarket($data_email);
             }
            //update truogn count trong bang project
            $this->home_model->upcountproject($id);
            //gui email
            // gui email cho khach hang co nguoi du thau va link xem thong tin nguoi du thau
            // gui email cho nguoi du thau va co link xem chi tiet thong tin cua du an "them thong tin nguoi gui

            $this->sendmailuser($id, $id_vip);
            $this->sendmail_vip($data['email'], $id, $data['name']);
            //echo 'test mail vip';

            echo '<script>alert("Bạn đã đăng ký dự thầu thành công. Thông tin liên hệ sẽ được gửi về email của bạn. Cảm ơn bạn đã sử dụng dịch vụ của chúng tôi!");
            window.location = "'.base_url().'du-an.html"
            </script>';

           // redirect('du-an.html');
        }

        $this->home_model->add_view($id);

        //noi dung
        $service_id = 1;
        $this->data['cates_da'] = $this->home_model->getCate(8);
        $this->data['cities'] = $this->home_model->get_city();
        $this->data['service_id'] = $service_id;
      // $this->data['data'] = get_home_news($service_id);

        $this->data['project'] = $this->home_model->detailProject($id);
        //echo $this->db->last_query();die;
        //echo '<pre>'; var_dump($this->data['project']); echo '</pre>';die;

        $this->load->view('header',$this->data);
        $this->load->view('detail_da',$this->data);
        $this->load->view('right_duan',$this->data);
        $this->load->view($this->footer);
    }
    /**
     * @param $id
     * @param $id_vip gui mail cho khach hang thong bao co nha thau du thau
     */
    function sendmailuser($id, $id_vip)
    {
       //go noi dung theo mau thu A3
        $linkdetailvip = base_url() . 'home/detail_user/'.$id_vip;
        $emailto = $this->home_model->detailProject($id);

        $mesnger = 'Chào bạn: <strong>' . $emailto['author'] . '</strong><br/><br/>';
        $mesnger .= ' <strong> Đã có đơn vị đăng kí dự thầu cho dự án của bạn :' . $emailto['title'] . '</strong>(Ngày đăng :12/9/2012 - Hết hạn : 20/8/2012)<br/><br/>';
        $mesnger .= ' Chúng tôi xin cung cấp thông tin giới thiệu về nhà thầu này cho bạn.
         Mời bạn xem qua Thông tin nhà thầu bằng cách click vào link bên dưới
         <a href="' . $linkdetailvip . '"><strong>Đây</strong></a><br/>';
        $mesnger .= 'Chúng tôi đã gửi thông tin liên hệ của bạn cho nhà thầu.
        Tiếp theo, nhà thầu sẽ trực tiếp liên hệ, tư vấn, báo giá cho bạn để thực hiện dự án này.
        Quyền quyết định nhà thầu là của bạn.<br/><br/>';
        $mesnger .= 'Nếu dự án thành công, bạn vui lòng thông báo cho Designs.vn để chúng tôi nắm được tình hình.
        Chúng tôi sẽ luôn theo sát để tiếp tục hỗ trợ bạn khi cần.  <br/><br/>';
        $mesnger  .= 'Thông tin nhân viên hỗ trợ:<br/>';
        $mesnger  .= 'Nguyễn Thị Ngọc Mai – Quản lý dự án <br/>';
        $mesnger  .= '<a href="'.base_url().'to-chuc-cuoc-thi-thiet-ke.html">Dịch vụ Môi giới dự án thiết kế - Designs.vn</a><br/>';
        $mesnger  .= 'Điện thoại: 0436950688 gặp Mai <br/>';
        $mesnger  .= 'Email: moigioiduan@designs.vn  <br/><br/><br/><br/>';
        $mesnger  .= '<h2> Xin cảm ơn.</h2> <br/>';

        send_mail_helper($emailto['email'], 'Thong tin dang ky du thau', $mesnger);
       // echo $ok;
    }

    /**
     * @param $data
     * @param $id gui mail cho nha thau thong bao thanh cong va link xem chi tiet du an
     */
    function sendmail_vip($mailto,$id, $name)
    {
        //go noi dung theo mau thu A2
        $linkdetailproject = base_url() . 'home/detail_project/' .$id;
        $mesnger = 'Chào bạn: <strong>' .$name. '</strong><br/><br/>';
        $mesnger .= ' <strong>Bạn đã Đăng ký dự thầu thành công cho dự án: '.$id.'</strong>
        (Ngày đăng: 12/08/2012 – Hết hạn: 20/08/2012) <br/><br/>';
        $mesnger .= 'Mời bạn xem qua Thông tin đầy đủ của dự án bằng cách click vào link bên dưới:
         <a href="' . $linkdetailproject . '"><strong>Đây</strong></a><br/>';
        $mesnger .= 'Chúng tôi đã gửi email giới thiệu về đơn vị của bạn cho khách hàng.
         Tiếp theo, bạn hãy trực tiếp liên hệ, tư vấn, báo giá cho khách hàng để thắng thầu dự án này. Sân chơi giờ là của bạn.<br/><br/>';
        $mesnger .= 'Nếu dự án thành công, bạn hãy gửi cho Designs.vn 10% phí môi giới như đã cam kết.
        Chúng tôi tin tưởng vào bạn để chúng ta có thể hợp tác lâu dài. <br/><br/>';
        $mesnger .= 'Thông tin liên hệ để thanh toán phí môi giới và được tư vấn:<br/>';
        $mesnger .= 'Nguyễn Thị Ngọc Mai – Quản lý dự án<br/>';
        $mesnger .= 'Dịch vụ Môi giới dự án thiết kế - Designs.vn <br/>';
        $mesnger .= 'Điện thoại: 0436950688 gặp Mai <br/>';
        $mesnger .= 'Email: moigioiduan@designs.vn <br/>';
        $mesnger .= 'Số tài khoản:  <br/>';
        $mesnger .= 'Chủ tài khoản: <br/><br/><br/>';
        $mesnger .= 'Xin cảm ơn. <br/>';

        send_mail_helper($mailto, 'Thong tin chi tiet du an da du thau', $mesnger);
    }
    //du an by cate
    function cate_da( $cate = 0,$page = 1,$service_id=8,$id=0)
    {
       // redirect(base_url().'moi-gioi-thiet-ke.html');
        $data['curent_cate'] = $this->home_model->getByUrl($cate);
        //echo '<pre>'; var_dump($data); echo '</pre>';die;
        //noi dung
        $service_id = 1;

        $this->data['cates_da'] = $this->cate_duan;
        $this->data['cities'] = $this->home_model->get_city();
        $this->data['service_id'] = $service_id;
      //  $this->data['data'] = get_home_news($service_id);

        $prefix = '';

        $numberget = 5;
        $start = ((int)$page - 1)*$numberget;
        $start = $start > 0 ? $start : 0;
        $this->data['projects'] = $this->home_model->getByCate(&$total,$data['curent_cate']->id, $start, $numberget);
        $config['base_url'] = base_url().'du-an/'.$cate.'_trang-';
        $config['total_rows'] = $total;
        $config['per_page'] = $numberget;
        $config['key'] = '.html';
        $config['cur_page'] = $start;
        $config['num_links'] = 5;
        $config['first_link'] = '';
        $config['last_link'] = '';
        $config['next_link'] = '>>';
        $config['prev_link'] = '<<';
        $config['cur_tag_open'] = '<li><a id="current">';
        $config['cur_tag_close'] = '</a></li>';

        $this->my_paginationhome->initialize($config);

        $this->data['paging'] = $this->my_paginationhome->create_links();

        $this->load->view('header',$this->data);
        $this->load->view('left_duan',$this->data);
        $this->load->view('right_duan',$this->data);
        $this->load->view('footer',$this->data);
    }
    //add du an
    function add_da($type = 0)
    {
       // redirect(base_url().'moi-gioi-thiet-ke.html');
        $data = array();
        if(isset( $_POST['submit']))
        {
            $data['title'] = htmlspecialchars(trim($_POST['title']));
            $data['cate_id'] = $_POST['cate_id'];
            $data['cities']  = $_POST['cities'];
            $data['content'] = $_POST['content'];
            $data['yeucau_cv'] = $_POST['yeucau_cv'];
            $data['ngansach']  = $_POST['ngansach'];
            $data['ngansach_num'] =   $_POST['ngansach_num'];
            $data['yeucau_cl'] = $_POST['yeucau_cl'];
            $data['date_start'] = $_POST['time_project'];
            $data['month_num'] = $_POST['month_num'];
            $data['yeucau_khac'] = $_POST['yeucau_khac'];
            $data['author'] = $_POST['name'];
            $data['phone'] = $_POST['phone'];
            $data['email'] = $_POST['email'];
            $data['status'] = 0;
            $data['date'] = time();
            $data['date_end'] = time()+ (20 * 24 * 60 * 60);
            $data['count'] = 0;
            $cate_name = $data['title'];
            $data['cate_code'] = standtext(Convert::convert_utf8_to_latin($cate_name));//convert string
            //echo '<pre>'; var_dump($data); echo '</pre>';die;

            if(!is_dir('public/media/media/thumb/'.date('m'))) mkdir('public/media/media/thumb/'.date('m'),0777);
            if(trim($_FILES["image_1"]['name'])!= ""){
                $config['upload_path'] = 'public/media/media/thumb/'.date('m');
                $config['allowed_types'] = 'gif|jpg|png|bmp|zip|pdf|doc';
                $config['max_size']	= '20480';
                $this->load->library('upload', $config);
                if ($this->upload->do_upload('image_1')){
                    $upload_data = $this->upload->data();
                    $sourcefile  = $config['upload_path'].'/'.$upload_data['file_name'];
                    $data['image_1'] = base_url().$sourcefile;
                }else $this->msg[] =  $this->upload->display_errors();
            }
            $this->load->library('image_lib');
            if(trim($_FILES["image_2"]['name'])!= ""){
                $config['upload_path'] = 'public/media/media/thumb/'.date('m');
                $config['allowed_types'] = 'gif|jpg|png|bmp|zip|pdf|doc';
                $config['max_size']	= '20480';
                $this->load->library('upload', $config);
                if ($this->upload->do_upload('image_2')){
                    $upload_data = $this->upload->data();
                    $sourcefile2  = $config['upload_path'].'/'.$upload_data['file_name'];
                    $data['image_2'] =  base_url().$sourcefile2;
                }else $this->msg[] =  $this->upload->display_errors();
            }
            $this->load->library('image_lib');
            if(trim($_FILES["image_3"]['name'])!= ""){
                $config['upload_path'] = 'public/media/media/thumb/'.date('m');
                $config['allowed_types'] = 'gif|jpg|png|bmp|zip|pdf|doc';
                $config['max_size']	= '20480';
                $this->load->library('upload', $config);
                if ($this->upload->do_upload('image_3')){
                    $upload_data = $this->upload->data();
                    $sourcefile3  = $config['upload_path'].'/'.$upload_data['file_name'];
                    $data['image_3'] =  base_url().$sourcefile3;
                }else $this->msg[] =  $this->upload->display_errors();
            }
            $this->load->library('image_lib');
            if(trim($_FILES["image_4"]['name'])!= ""){
                $config['upload_path'] = 'public/media/media/thumb/'.date('m');
                $config['allowed_types'] = 'gif|jpg|png|bmp|zip|pdf|doc';
                $config['max_size']	= '20480';
                $this->load->library('upload', $config);
                if ($this->upload->do_upload('image_4')){
                    $upload_data = $this->upload->data();
                    $sourcefile4  = $config['upload_path'].'/'.$upload_data['file_name'];
                    $data['image_4'] =  base_url().$sourcefile4;
                }else $this->msg[] =  $this->upload->display_errors();
            }
            $this->load->library('image_lib');
            if(trim($_FILES["image_5"]['name'])!= ""){
                $config['upload_path'] = 'public/media/media/thumb/'.date('m');
                $config['allowed_types'] = 'gif|jpg|png|bmp|zip|pdf|doc';
                $config['max_size']	= '20480';
                $this->load->library('upload', $config);
                if ($this->upload->do_upload('image_5')){
                    $upload_data = $this->upload->data();
                    $sourcefile5  = $config['upload_path'].'/'.$upload_data['file_name'];
                    $data['image_5'] =  base_url().$sourcefile5;
                }else $this->msg[] =  $this->upload->display_errors();
            }
            $this->load->library('image_lib');
            if(trim($_FILES["image_6"]['name'])!= ""){
                $config['upload_path'] = 'public/media/media/thumb/'.date('m');
                $config['allowed_types'] = 'gif|jpg|png|bmp|zip|pdf|doc';
                $config['max_size']	= '20480';
                $this->load->library('upload', $config);
                if ($this->upload->do_upload('image_6')){
                    $upload_data = $this->upload->data();
                    $sourcefile6  = $config['upload_path'].'/'.$upload_data['file_name'];
                    $data['image_6'] =  base_url().$sourcefile6;
                }else $this->msg[] =  $this->upload->display_errors();
            }

            //ket thuc hinh anh
            //echo '<pre>'; var_dump($data); echo '</pre>';die;
            $this->home_model->addProject($data);
            echo '<script>alert("Bạn đã gửi yêu cầu dự án thành công");
            window.location = "'.base_url().'du-an.html"
            </script>';
           // redirect('du-an.html');
        }
    }
    //add user
    function add_vip()
    {
       // redirect(base_url().'moi-gioi-thiet-ke.html');
        $data = array();
        if(isset( $_POST['submit']))
        {
            $data['name'] = htmlspecialchars(trim($_POST['namer']));
            $data['chuyen_mon']  = $_POST['chuyenmonr'];
            $data['cities']  = $_POST['citiesr'];
            $data['phone']  = $_POST['phoner'];
            $data['email']  = $_POST['emailr'];
            $data['link_contact']  = $_POST['linkr'];
            $data['status']  = 0;
            $data['date']  = time();;
            $data['web']  = $_POST['webr'];

            if(!is_dir('public/media/media/file/'.date('m'))) mkdir('public/media/media/file/'.date('m'),0777);
            if(trim($_FILES["hoso1r"]['name'])!= ""){
                $config['upload_path'] = 'public/media/media/file/'.date('m');
                $config['allowed_types'] = 'gif|jpg|png|bmp|zip|pdf|doc';
                $config['max_size']	= '20480';
                $this->load->library('upload', $config);
                if ($this->upload->do_upload('hoso1')){
                    $upload_data = $this->upload->data();
                    $sourcefile  = $config['upload_path'].'/'.$upload_data['file_name'];
                    $data['hoso1'] = base_url().$sourcefile;
                }else $this->msg[] =  $this->upload->display_errors();
            }
            $this->load->library('image_lib');
            if(trim($_FILES["hoso2r"]['name'])!= ""){
                $config['upload_path'] = 'public/media/media/file/'.date('m');
                $config['allowed_types'] = 'gif|jpg|png|bmp|zip|pdf|doc';
                $config['max_size']	= '20480';
                $this->load->library('upload', $config);
                if ($this->upload->do_upload('hoso2')){
                    $upload_data = $this->upload->data();
                    $sourcefile2  = $config['upload_path'].'/'.$upload_data['file_name'];
                    $data['hoso2'] =  base_url().$sourcefile2;
                }else $this->msg[] =  $this->upload->display_errors();
            }
            $this->load->library('image_lib');
            if(trim($_FILES["hoso3r"]['name'])!= ""){
                $config['upload_path'] = 'public/media/media/file/'.date('m');
                $config['allowed_types'] = 'gif|jpg|png|bmp|zip|pdf|doc';
                $config['max_size']	= '20480';
                $this->load->library('upload', $config);
                if ($this->upload->do_upload('hoso3')){
                    $upload_data = $this->upload->data();
                    $sourcefile3  = $config['upload_path'].'/'.$upload_data['file_name'];
                    $data['hoso3'] =  base_url().$sourcefile3;
                }else $this->msg[] =  $this->upload->display_errors();
            }
            //echo '<pre>'; var_dump($sourcefile); echo '</pre>';die;
            
            $this->home_model->addUserVip($data);
             $emails = $this->home_model->getAllMail($data['email']);
             if(!$emails){
                $data_email = array(
                    'ten_dv'=> $data['name'],
                    'linhvuc' =>  $data['chuyen_mon'],
                    'phone' => $data['phone'],
                    'email'=>$data['email'],
                    'cities'=>  $data['cities'],
                    'website'=>$data['web'],
                    'phan_loai' => 'VIP',
                    'group' =>1,
                    'status'=> 0,
                    'date' => time()
                );
                $this->home_model->addEmailMarket($data_email);
             }
            echo '<script>alert("Bạn đã đăng ký thông tin thành công");
            window.location = "'.base_url().'du-an.html"
            </script>';

           // redirect('du-an.html');
        }
    }
    //add mail
    function add_email_market()
    {
       // redirect(base_url().'moi-gioi-thiet-ke.html');
        $data = array();
        if(isset( $_POST['submit']))
        {
            $data['ten_dv'] = htmlspecialchars(trim($_POST['name']));
            $data['linhvuc']  = $_POST['linhvuc'];
            $data['cities']  = $_POST['cities'];
            $data['phone']  = $_POST['phone'];
            $data['email']  = $_POST['email'];
            $data['phan_loai'] = 'Mới đăng ký';
            $data['group'] = 1;
            $data['status']  = 0;
            $data['date']  = time();;
            $emails = $this->home_model->getAllMail($data['email']);
            if(!$emails)
            {
                $this->home_model->addEmailMarket($data);
                echo '<script>
                alert("Bạn đã đăng ký thông tin thành công");
                window.location = "'.base_url().'du-an.html"
                </script>';
            }
            echo '<script>
                alert("mail da ton tai");
                window.location = "'.base_url().'du-an.html"
                </script>';

          //  redirect('du-an.html');
        }
    }
    //chi tiet 1 du an
    function detail_project($sevice_id = 0 ,$id = 0)
    {
       //redirect(base_url().'moi-gioi-thiet-ke.html');
        $id = $this->uri->segment(3);
        //echo '<pre>'; var_dump($id); echo '</pre>';die;
        $this->home_model->add_view($id);

        $detail = $this->home_model->detailProject($id);
        if($detail)
        {
            $service_id = 1;
            $this->data['cates_da'] = $this->home_model->getCate(8);
            $this->data['cities'] = $this->home_model->get_city();
            $this->data['service_id'] = $service_id;
            $this->data['data'] = get_home_news($service_id);

            $this->data['project'] = $this->home_model->detailProject($id);
            //echo $this->db->last_query();die;
            //echo '<pre>'; var_dump($this->data['project']); echo '</pre>';die;

            $this->load->view('header',$this->data);
            $this->load->view('detail_project',$this->data);
            $this->load->view('right_duan',$this->data);
            $this->load->view($this->footer);
        }
        else redirect('du-an.html');
        //noi dung
    }
    //chi tiet user
    function detail_user()
    {

        $id_user = $this->uri->segment(3);
        $service_id = 1;
        $this->data['service_id'] = $service_id;

        $detail = $this->home_model->getUserByIdDa($id_user);

        if($detail)
        {
            $this->data['users'] = $detail;
            $this->load->view('header',$this->data);
            $this->load->view('detail_user',$this->data);
            $this->load->view('right_duan',$this->data);
            $this->load->view($this->footer);
        }
        else redirect('du-an.html');
    }
    //add commment
	function add_comment()
	{
		$name = isset($_POST['name']) ? $_POST['name'] : '';
		$email = isset($_POST['email']) ? $_POST['email'] : '';
		$content = isset($_POST['content']) ? $_POST['content'] : '';
		$code = isset($_POST['code']) ? $_POST['code'] : '';
        $idnews = isset($_POST['idnews']) ? $_POST['idnews'] : '';

        $ques['name'] = $name;
		$ques['email'] = $email;
        if(check_login_user())
        {
            $ques['user_id'] = info_from_session_user(0);
            $ques['email'] = info_from_session_user(5);
            $ques['name'] = info_from_session_user(1);
        }
		$ques['content'] = $content;
		$ques['date'] = time();
		$ques['status'] = 1;
		$ques['id_news'] = $idnews;
		$ques['news_title'] = isset($_POST['news_title']) ? $_POST['news_title'] : '';
        //echo '<pre>'; var_dump($ques); echo '</pre>';die;
		
		if(check_captcha($code) && $this->home_model->add_comment($ques))
		{
            if(isset($_POST['sendu']) && $_POST['sendu'])
            {
                $tmp = explode(',', trim($_POST['sendu'],', '));
                if($tmp)
                {

                    foreach($tmp as $u)
                    {
                        $in = array();
                        $in['from_id'] = info_from_session_user(0);
                        $in['from_user'] = info_from_session_user(1);
                        $in['to_user'] = trim($u);
                        $in['news_title'] = $ques['news_title'];
                        $in['news_code'] = isset($_POST['news_code']) ? $_POST['news_code'] : '';
                        $in['news_id'] = $ques['id_news'];
                        $in['date'] = time();
                        $this->home_model->addtagu($in);
                    }
                }
            }
			$msg = "Viết bình luận thành công.";
			$data = array('success'=>1 , 'message'=>$msg);
		} 
		else $data = array('message'=>'Mã xác nhận bảo mật không đúng.');
		
		echo json_encode($data);
	}

	//danh ba cac list con cua danh ba

	function list_contact($service = 5)
	{
	    $this->number_statistic = 5;
		$this->add_comtact();
		$service_id = (int)$service;
		$this->cates = $this->home_model->get_cate_contact();
        //echo '<pre>'; var_dump($this->cates ); echo '</pre>';die;
		$data = $this->home_model->list_contact(-1 , 0 , $this->number_get_contact);
		$this->data['items'] = $data['result'];
        $this->data['topview'] = $this->home_model->contact_statistic(-1,'view' , 0 , $this->number_statistic);
        $this->data['topnew'] = $this->home_model->contact_statistic(-1,'date_create' , 0 , $this->number_statistic);
        $this->data['topedit'] = $this->home_model->contact_statistic(-1,'date_edit' , 0 , $this->number_statistic);

		$this->data['title'] = 'Danh bạ thiết kế  - www.designs.vn';
		$this->data['description']    = 'Tin tức ngành thiết kế, quảng cáo và nghệ thuật Việt Nam và Thế giới.';
		$this->data['keywords']       = 'Noithat: Thietkenoithat, Thietke, tubep, Noithat, phong ngu, Thiet ke kien truc, Noithat, vanphong, Thietke, kientruc, Thietke nha o, Thietke, khachsan, Thietke nhahang, Quanly duan, Tu van, Nha thau, Sofa, Chieu sang, Den chum,Thiet ke quang cao
                                        Thiet ke do hoa, Thiet le logo, Thiet ke thuong hieu, Thiet ke bao bi, Thiet ke slogan, Thiet ke in an, Thiet ke poster, Nha in, Quang cao, Truyen thong, Su kien, Media, Truyen hinh, Bao chi, Vat lieu xay dung
                                        Vat lieu noi that, Cua hang noi that, Thiet bi ve sinh, Thiet bi nha bep, Thu cong my nghe, Dao tao thiet ke, Studio, Nguoi mau, Nghe si,Hoa si, Thoi trang, Nghe thuat, Danh ba, Danh ba thiet ke
                                        Danh ba quang cao, Cuoc thi, Cuoc thi thiet ke, Cac cuoc thi, Giai thuong thiet ke, Tuyen dung, Viec lam thiet ke, Tuyen Kien truc su, Tuyen Designer, Nhan vien thiet ke, Thiet ke san pham, Tao dang cong nghiep, Thiet ke thoi trang';
		$this->data['cate_code'] = '';
		$this->data['service_id'] = $service_id;
		$this->data['local'] = $this->home_model->get_city();
        $this->header = 'header-contact';
		$this->load->view($this->header, $this->data);
        $this->load->view('left_contact' , $this->data);
        $this->load->view('contact_home' , $this->data);
		$this->load->view('right_contact' , $this->data);
		$this->load->view('footer_contact' , $this->data);
	}

	private function add_comtact()
	{
		$data = array();
		
		if ( isset( $_POST['submit'] )) {			
			$data     = $_POST['data'];
			$tmp = explode('|', $data['cate_code']);
			$data['cate_code'] = @$tmp[1];
			$data['cate_name'] = @$tmp[2];
			$data['id_cate'] = (int)$tmp[0];
            $data['user_type'] = 1;
            $data['business_scope'] = $data['cate_name'];
            $data['business_scope'] .= ((isset($_POST['business_scope1']) && $_POST['business_scope1'] != -1) ? ', '.$_POST['business_scope1'] : '');
            $data['business_scope'] .= ((isset($_POST['business_scope2']) && $_POST['business_scope2'] != -1) ? ', '.$_POST['business_scope2'] : '');
            $data['date_create'] = time();
			//var_dump($_FILES);
            // thực hiện upload hình ảnh
                if(!is_dir('public/media/media/thumb/'.date('m'))) mkdir('public/media/media/thumb/'.date('m'),0777);
                    if(trim($_FILES["thumb_img"]['name'])!= ""){
                        $config['upload_path'] = 'public/media/media/thumb/'.date('m');
                        $config['allowed_types'] = 'gif|jpg|png|bmp';
                        $config['max_size']	= '20480';
                        $this->load->library('upload', $config);
                        if ($this->upload->do_upload('thumb_img')){
                            $upload_data = $this->upload->data();
                            $sourcefile  = $config['upload_path'].'/'.$upload_data['file_name'];
                                $config_crop['image_library'] = 'gd2';
                                $config_crop['source_image'] = $sourcefile;
                                $config_crop['create_thumb'] = TRUE;
                                $config_crop['maintain_ratio'] = FALSE;
                                $config_crop['thumb_marker'] = '';
                                $config_crop['width'] = 165;
                                $config_crop['height'] = 121;
                                $this->load->library('image_lib', $config_crop);
                                $this->image_lib->resize();
                                $data['logo'] = base_url().$sourcefile;
                        }else $this->msg[] =  $this->upload->display_errors();
                }
                $this->load->library('image_lib');
                if(trim($_FILES["img_1"]['name'])!= ""){
                    $config['upload_path'] = 'public/media/media/thumb/'.date('m');
                    $config['allowed_types'] = 'gif|jpg|png|bmp';
                    $config['max_size']	= '20480';
                    $this->load->library('upload', $config);
                    if ($this->upload->do_upload('img_1')){
                        $upload_data = $this->upload->data();
                        $sourcefile  = $config['upload_path'].'/'.$upload_data['file_name'];
                            $config_crop['image_library'] = 'gd2';
                            $config_crop['source_image'] = $sourcefile;
                            $config_crop['create_thumb'] = TRUE;
                            $config_crop['maintain_ratio'] = FALSE;
                            $config_crop['thumb_marker'] = '_dsthumb';
                            $config_crop['width'] = 157;
                            $config_crop['height'] = 117;
                            $this->image_lib->initialize($config_crop);
                            $this->image_lib->resize();
                            $data['img_1'] =  base_url().get_url_thumb($this->image_lib->full_dst_path);
                    }else $this->msg[] =  $this->upload->display_errors();
                }
                if(trim($_FILES["img_2"]['name'])!= ""){
                    $config['upload_path'] = 'public/media/media/thumb/'.date('m');
                    $config['allowed_types'] = 'gif|jpg|png|bmp';
                    $config['max_size']	= '20480';
                    $this->load->library('upload', $config);
                    if ($this->upload->do_upload('img_2')){
                        $upload_data = $this->upload->data();
                        $sourcefile  = $config['upload_path'].'/'.$upload_data['file_name'];
                        $config_crop['image_library'] = 'gd2';
                        $config_crop['source_image'] = $sourcefile;
                        $config_crop['create_thumb'] = TRUE;
                        $config_crop['maintain_ratio'] = FALSE;
                        $config_crop['thumb_marker'] = '_dsthumb';
                        $config_crop['width'] = 157;
                        $config_crop['height'] = 117;
                        $this->image_lib->initialize($config_crop);
                        $this->image_lib->resize();
                        $data['img_2'] =  base_url().get_url_thumb($this->image_lib->full_dst_path);
                    }else $this->msg[] =  $this->upload->display_errors();
                }
                if(trim($_FILES["img_3"]['name'])!= ""){
                    $config['upload_path'] = 'public/media/media/thumb/'.date('m');
                    $config['allowed_types'] = 'gif|jpg|png|bmp';
                    $config['max_size']	= '20480';
                    $this->load->library('upload', $config);
                    if ($this->upload->do_upload('img_3')){
                        $upload_data = $this->upload->data();
                        $sourcefile  = $config['upload_path'].'/'.$upload_data['file_name'];
                            $config_crop['image_library'] = 'gd2';
                            $config_crop['source_image'] = $sourcefile;
                            $config_crop['create_thumb'] = TRUE;
                            $config_crop['maintain_ratio'] = FALSE;
                            $config_crop['thumb_marker'] = '_dsthumb';
                            $config_crop['width'] = 157;
                            $config_crop['height'] = 117;
                            $this->image_lib->initialize($config_crop);
                            $this->image_lib->resize();
                            $data['img_3'] =  base_url().get_url_thumb($this->image_lib->full_dst_path);
                    }else $this->msg[] =  $this->upload->display_errors();
                }
                if(trim($_FILES["img_4"]['name'])!= ""){
                    $config['upload_path'] = 'public/media/media/thumb/'.date('m');
            		$config['allowed_types'] = 'gif|jpg|png|bmp';
            		$config['max_size']	= '20480';
            		$this->load->library('upload', $config);
            		if ($this->upload->do_upload('img_4')){
            		    $upload_data = $this->upload->data();
    	                $sourcefile  = $config['upload_path'].'/'.$upload_data['file_name'];
                            $config_crop['image_library'] = 'gd2';
                            $config_crop['source_image'] = $sourcefile;
                            $config_crop['create_thumb'] = TRUE;
                            $config_crop['maintain_ratio'] = FALSE;
                            $config_crop['thumb_marker'] = '_dsthumb';
                            $config_crop['width'] = 157;
                            $config_crop['height'] = 117;                            
                            $this->image_lib->initialize($config_crop);                            
                            $this->image_lib->resize();                                
                            $data['img_4'] =  base_url().get_url_thumb($this->image_lib->full_dst_path);                  
            		}else $this->msg[] =  $this->upload->display_errors();
                }
                if(trim($_FILES["img_5"]['name'])!= ""){
                    $config['upload_path'] = 'public/media/media/thumb/'.date('m');
            		$config['allowed_types'] = 'gif|jpg|png|bmp';
            		$config['max_size']	= '20480';
            		$this->load->library('upload', $config);
            		if ($this->upload->do_upload('img_5')){
            		    $upload_data = $this->upload->data();
    	                $sourcefile  = $config['upload_path'].'/'.$upload_data['file_name'];
                            $config_crop['image_library'] = 'gd2';
                            $config_crop['source_image'] = $sourcefile;
                            $config_crop['create_thumb'] = TRUE;
                            $config_crop['maintain_ratio'] = FALSE;
                            $config_crop['thumb_marker'] = '_dsthumb';
                            $config_crop['width'] = 157;
                            $config_crop['height'] = 117;                            
                            $this->image_lib->initialize($config_crop);                            
                            $this->image_lib->resize();                                
                            $data['img_5'] =  base_url().get_url_thumb($this->image_lib->full_dst_path);                   
            		}else $this->msg[] =  $this->upload->display_errors();
                }
                if(trim($_FILES["img_6"]['name'])!= ""){
                    $config['upload_path'] = 'public/media/media/thumb/'.date('m');
            		$config['allowed_types'] = 'gif|jpg|png|bmp';
            		$config['max_size']	= '20480';
            		$this->load->library('upload', $config);
            		if ($this->upload->do_upload('img_6')){
            		    $upload_data = $this->upload->data();
    	                $sourcefile  = $config['upload_path'].'/'.$upload_data['file_name'];
                            $config_crop['image_library'] = 'gd2';
                            $config_crop['source_image'] = $sourcefile;
                            $config_crop['create_thumb'] = TRUE;
                            $config_crop['maintain_ratio'] = FALSE;
                            $config_crop['thumb_marker'] = '_dsthumb';
                            $config_crop['width'] = 157;
                            $config_crop['height'] = 117;                            
                            $this->image_lib->initialize($config_crop);                            
                            $this->image_lib->resize();                                
                            $data['img_6'] =  base_url().get_url_thumb($this->image_lib->full_dst_path);                  
            		}else $this->msg[] =  $this->upload->display_errors();
                }
            //ket thuc hinh anh
        
			if ( trim($data['company']) == '' )
				$this->msg[] = 'Tên công ty không được để trống';
			if ( trim($data['address']) == '' )
				$this->msg[] = 'Địa chỉ không được để trống';
			$this->load->helper('email');
			if(!valid_email($data['email'])) $this->msg[] = 'Email không hợp lệ.';
            if(!info_from_session_user(1)) $this->msg[] = "Bạn chưa đăng nhập";
            else{
                $data['username'] = info_from_session_user(1);
            }
			if ( count($this->msg) == 0 ) {				
				if($this->home_model->add_contact( $data ))
				{
					$this->msg[] = 'Gửi đăng ký thành công. Hồ sơ của bạn sẽ được duyệt trong vòng 48 giờ. Vui lòng kiểm tra thông báo tại email đăng ký của bạn.';
                    $this->load->helper('mail');
                    $mesnger = file_get_contents('public/sendmail/html_mail_addcontact.html');
                    $mesnger = str_replace('{company}',$data['company'],$mesnger);
                    $mesnger = str_replace('{address}',$data['address'],$mesnger);
                    $mesnger = str_replace('{email}',$data['email'],$mesnger);
                         
                    $ok = send_mail_helper($data['email'],'Thông báo thành viên đăng ký danh bạ mới',$mesnger);
					$data = array();
				} 
			}		
		}
	}
    //hien thi trang trong danh muc
	function list_cate_contact($service = 5 , $cate_code=-1,$page = 1)
	{
	   //$this->output->cache($this->timecate);
		$this->number_get_contact = 20;
		$service_id = (int)$service;
		$start = ((int)$page - 1)*$this->number_get_contact;
		$start = $start > 0 ? $start : 0;
		$cate_code = mysql_escape_string($cate_code);

		$this->cates = $this->home_model->get_cate_contact();
		
		$data = $this->home_model->list_contact($cate_code , $start , $this->number_get_contact);
		
		$config['base_url'] = base_url().'danh-ba-thiet-ke'.($cate_code == -1 ? '_trang-' : '/'.$cate_code.'_trang-');
		$config['total_rows'] = $data['total'];
		$config['per_page'] = $this->number_get_contact;
		$config['key'] = '.html';
		$config['cur_page'] = $start;
		$config['num_links'] = 5;
		$config['first_link'] = '';
		$config['last_link'] = '';
		$config['next_link'] = '>>';
		$config['prev_link'] = '<<';
		$config['cur_tag_open'] = '<li><a id="current">';
		$config['cur_tag_close'] = '</a></li>';
		
		$this->my_paginationhome->initialize($config);
		
		$this->data['paging'] = $this->my_paginationhome->create_links();
		
		$this->data['items'] = $data['result'];
		$this->data['title'] = 'Danh bạ thiết kế  - www.designs.vn';
		$this->data['description']=
            'Danh bạ các công ty thiết kế, quảng cáo,nhà cung cấp vật liệu xây dựng, nội thất ...';
		$this->data['keywords']=
            'Noithat: Thietkenoithat, Thietke, tubep, Noithat, phong ngu, Thiet ke kien truc, Noithat, vanphong, Thietke, kientruc, Thietke nha o, Thietke, khachsan, Thietke nhahang, Quanly duan, Tu van, Nha thau, Sofa, Chieu sang, Den chum,Thiet ke quang cao
            Thiet ke do hoa, Thiet le logo, Thiet ke thuong hieu, Thiet ke bao bi, Thiet ke slogan, Thiet ke in an, Thiet ke poster, Nha in, Quang cao, Truyen thong, Su kien, Media, Truyen hinh, Bao chi, Vat lieu xay dung
            Vat lieu noi that, Cua hang noi that, Thiet bi ve sinh, Thiet bi nha bep, Thu cong my nghe, Dao tao thiet ke, Studio, Nguoi mau, Nghe si,Hoa si, Thoi trang, Nghe thuat, Danh ba, Danh ba thiet ke
            Danh ba quang cao, Cuoc thi, Cuoc thi thiet ke, Cac cuoc thi, Giai thuong thiet ke, Tuyen dung, Viec lam thiet ke, Tuyen Kien truc su, Tuyen Designer, Nhan vien thiet ke, Thiet ke san pham, Tao dang cong nghiep, Thiet ke thoi trang';
        $this->data['cate_code'] = $cate_code;
		$this->data['service_id'] = $service_id;
		$this->data['local'] = $this->home_model->get_city();
        $this->data['topview'] = $this->home_model->contact_statistic($cate_code,'view' , 0 , $this->number_statistic);
        $this->data['topnew'] = $this->home_model->contact_statistic($cate_code,'date_create' , 0 , $this->number_statistic);
        $this->data['topedit'] = $this->home_model->contact_statistic($cate_code,'date_edit' , 0 , $this->number_statistic);
		$this->header = 'header-contact';
		$this->load->view($this->header , $this->data);
		$this->load->view('left_contact' , $this->data);
        $this->load->view('contact_list' , $this->data);
        $this->load->view('right_contact' , $this->data);
		$this->load->view('footer_contact' , $this->data);
	}
    //hien thi mot tin tuc theo id,trong danh muc con cua danh ba
	function detail_contact($service = 5 , $id = 0)
	{
	    $id = (int)$id;
	    $this->home_model->update_contact_view($id);
	    //$this->output->cache($this->timecate);
		$service_id = (int)$service;
		$id = (int)$id;
		$this->cates = $this->home_model->get_cate_contact();
		$data = $this->home_model->detail_contact($id);
		if(!$data) redirect();
		
		$this->data['title'] = 'Danh bạ thiết kế  - www.designs.vn';
		$this->data['description']    = 'Danh bạ các công ty thiết kế, quảng cáo, nhà cung cấp vật liệu xây dựng, nội thất ...';
		$this->data['keywords']       = 'Noithat: Thietkenoithat, Thietke, tubep, Noithat, phong ngu, Thiet ke kien truc, Noithat, vanphong, Thietke, kientruc, Thietke nha o, Thietke, khachsan, Thietke nhahang, Quanly duan, Tu van, Nha thau, Sofa, Chieu sang, Den chum,Thiet ke quang cao
                                        Thiet ke do hoa, Thiet le logo, Thiet ke thuong hieu, Thiet ke bao bi, Thiet ke slogan, Thiet ke in an, Thiet ke poster, Nha in, Quang cao, Truyen thong, Su kien, Media, Truyen hinh, Bao chi, Vat lieu xay dung
                                        Vat lieu noi that, Cua hang noi that, Thiet bi ve sinh, Thiet bi nha bep, Thu cong my nghe, Dao tao thiet ke, Studio, Nguoi mau, Nghe si,Hoa si, Thoi trang, Nghe thuat, Danh ba, Danh ba thiet ke
                                        Danh ba quang cao, Cuoc thi, Cuoc thi thiet ke, Cac cuoc thi, Giai thuong thiet ke, Tuyen dung, Viec lam thiet ke, Tuyen Kien truc su, Tuyen Designer, Nhan vien thiet ke, Thiet ke san pham, Tao dang cong nghiep, Thiet ke thoi trang';
		$this->data['cate_code'] = $data['cate_code'];
		$this->data['service_id'] = $service_id;
		$this->data['local'] = $this->home_model->get_city();
		$this->data['item'] = $data;
        
        $this->data['topview'] = $this->home_model->contact_statistic($data['cate_code'],'view' , 0 , $this->number_statistic);
        $this->data['topnew'] = $this->home_model->contact_statistic($data['cate_code'],'date_create' , 0 , $this->number_statistic);
        $this->data['topedit'] = $this->home_model->contact_statistic($data['cate_code'],'date_edit' , 0 , $this->number_statistic);
        $this->data['other'] = $this->home_model->contact_scale($data['cate_code'], $data['id'] , $data['scale'], 0 , $this->number_statistic);
		$this->header = 'header-contact';
        $this->load->view($this->header , $this->data);
        $this->load->view('left_contact' , $this->data);
		$this->load->view('contact_detail' , $this->data);
        $this->load->view('right_contact' , $this->data);
		$this->load->view('footer_contact' , $this->data);
        
	}
    //tin doc nhieu
	function top_news($page=1)
	{
	    //$this->output->cache($this->timecate);
	    $this->events = $this->home_model->list_event(0 , 3);
		//$this->jobs = $this->home_model->list_new_job(JOB_TYPE_JOB,0,8);
		$this->top_news = $this->home_model->top_news(0,$this->numtopnews*3);

		//$this->news_focus  =   $this->home_model->get_news_focus(0,9,1);
		//$this->quatang = $this->home_model->get_quatang();
        
        // v3
        $this->video = $this->home_model->list_news_cate('video',0,3);
        $this->images = $this->home_model->list_news_cate('nhiep-anh',0,3);
        $this->discovery = $this->home_model->list_news_discover('tieu-diem' , 0 , $this->numdiscovery*3);
        //chuyen de
        $this->group = $this->home_model->list_group_home(0 ,$this->numgroup*3);
        /*---------------V4 --------------------*/
        $this->idear = get_idears(15);
        $this->onlydesigns = get_only_designs();
        $this->catecontact = $this->home_model->get_cate_contact();
        
		$service_id = 1;
		$start = ((int)$page - 1)*$this->number_get_news;
		$start = $start > 0 ? $start : 0;
		
		$data = $this->home_model->top_home_news($start , $this->number_get_news , "view");
		//echo '<pre>'; var_dump($data); echo '</pre>';die;
		$config['base_url'] = base_url().'tin-doc-nhieu-nhat_trang-';
		$config['total_rows'] = $data['total'];
		$config['per_page'] = $this->number_get_news;
		$config['key'] = '.html';
		$config['cur_page'] = $start;
		$config['num_links'] = 5;
		$config['first_link'] = '';
		$config['last_link'] = '';
		$config['next_link'] = '>>';
		$config['prev_link'] = '<<';
		$config['cur_tag_open'] = '<li><a id="current">';
		$config['cur_tag_close'] = '</a></li>';
		
		$this->my_paginationhome->initialize($config);
		
		$this->data['paging'] = $this->my_paginationhome->create_links();
		
		$this->cates = get_menu($service_id);
		$this->data['title'] = 'Tin đọc nhiều nhất - www.designs.vn';
		$this->data['description']=
            'Danh bạ thiết kế, Cuộc thi thiết kế, Giải thưởng thiết kế, Việc làm thiết kế, Các sự kiện, Kiến trúc, Nội thất, Đồ họa, Quảng cáo, Hội họa, Nhiếp ảnh, Điện ảnh, Thời trang, Thiết kế sản phẩm.';
		$this->data['keywords'] =
            'Noithat: Thietkenoithat, Thietke, tubep, Noithat, phong ngu, Thiet ke kien truc, Noithat, vanphong, Thietke, kientruc, Thietke nha o, Thietke, khachsan, Thietke nhahang, Quanly duan, Tu van, Nha thau, Sofa, Chieu sang, Den chum,Thiet ke quang cao
            Thiet ke do hoa, Thiet le logo, Thiet ke thuong hieu, Thiet ke bao bi, Thiet ke slogan, Thiet ke in an, Thiet ke poster, Nha in, Quang cao, Truyen thong, Su kien, Media, Truyen hinh, Bao chi, Vat lieu xay dung
            Vat lieu noi that, Cua hang noi that, Thiet bi ve sinh, Thiet bi nha bep, Thu cong my nghe, Dao tao thiet ke, Studio, Nguoi mau, Nghe si,Hoa si, Thoi trang, Nghe thuat, Danh ba, Danh ba thiet ke
            Danh ba quang cao, Cuoc thi, Cuoc thi thiet ke, Cac cuoc thi, Giai thuong thiet ke, Tuyen dung, Viec lam thiet ke, Tuyen Kien truc su, Tuyen Designer, Nhan vien thiet ke, Thiet ke san pham, Tao dang cong nghiep, Thiet ke thoi trang';
	    $this->data['cate_code'] = '';
		$this->data['service_id'] = $service_id;
		$this->data['local'] = $this->home_model->get_city();
		$this->data['items'] = $data['result'];
		
		$this->load->view($this->header , $this->data);
        $this->load->view('left_home' , $this->data);
        $this->load->view('top_news' , $this->data);
		$this->load->view('right_home' , $this->data);
		$this->load->view($this->footer , $this->data);
	}

    //viec lam

	function list_job($service = 3, $type = 1,$cate_code=-1 , $page = 1)
	{
	
        //$this->number_get_news = 1;
		$service_id = (int)$service;
		$num_type =($type == 'cho-ung-vien' ? JOB_TYPE_JOB : JOB_TYPE_SEEKER);

        		if(isset($_POST['submit']))
		{
			$data = $_POST['data'];
			$data['job_type'] = ($num_type == JOB_TYPE_JOB ? JOB_TYPE_SEEKER : JOB_TYPE_JOB) ;
			$data['job_date_create'] = time();
			$tmp = explode('|',$_POST['cate']);
			$data['job_cate'] = @$tmp[0];//@ k show loi
			$data['job_cate_name'] = @$tmp[2];
			$data['job_cate_code'] = @$tmp[1];
            $data['order'] = substr(time(), 4,6);
			if(count($tmp) != 3) $this->msg[] = "Bạn chưa chọn ngành nghề.";
			if(count($this->msg) == 0 && $this->home_model->add_job($data)) $this->msg[] = 'Bạn đã thêm mới hồ sơ thành công.Chúng tôi sẽ xem xét hồ sơ của bạn sớm nhất có thể';
		}
		
		$start = ((int)$page - 1)*$this->number_get_news;
		$start = $start > 0 ? $start : 0;
		$this->cates = $this->home_model->get_cate_job($num_type);
		$data = $this->home_model->list_job($cate_code , $num_type , $start , $this->number_get_news);
         $this->data['textsearch'] = $num_type == JOB_TYPE_JOB ? 'Tìm trong việc làm' : 'Tìm trong hồ sơ';
        $this->data['fsearch'] = 'searchjob('.$num_type.')';
		
		$config['base_url'] = base_url().'viec-lam/'.$type.'_trang-';
		$config['total_rows'] = $data['total'];
		$config['per_page'] = $this->number_get_news;
		$config['key'] = '.html';
		$config['cur_page'] = $start;
		$config['num_links'] = 5;
		$config['first_link'] = '';
		$config['last_link'] = '';
		$config['next_link'] = '>>';
		$config['prev_link'] = '<<';
		$config['cur_tag_open'] = '<li><a id="current">';
		$config['cur_tag_close'] = '</a></li>';
		
		$this->my_paginationhome->initialize($config);
		
		$this->data['paging'] = $this->my_paginationhome->create_links();
		
		$dcate = $this->home_model->detail_cate_closure($cate_code);
		$this->data['title'] = (isset($dcate['name']) ? $dcate['name'].' - ' : '').' Việc làm thiết kế '.($type == 'cho-ung-vien' ? 'cho ứng viên ' : 'cho tổ chức ').' - www.designs.vn';
		$this->data['description'] = 'Thông tin đầy đủ nhất về việc làm trong ngành thiết kế, quảng cáo và nghệ thuật.';
		$this->data['keywords']       = 'Viec lam thiet ke, tim viec lam, tuyen dung, nhan su, thiet ke, nhan vien thiet ke, my thuat, kien truc, noi that, do hoa, nhiep anh, thiet ke website, nhan vien marketing, quang cao, nhan vien ve, thoi trang, tu van giam sat, xay dung.';
		$this->data['cate_code'] = $type;
		$this->data['service_id'] = $service_id;
		$this->data['local'] = $this->home_model->get_city();
		$this->data['items'] = $data['result'];
		$this->data['str'] = "Hiển thị ".($data['total'] > 0 ? ($start +1) : 0)." tới ".(($start+$this->number_get_news) > $data['total'] ? $data['total'] : ($start+$this->number_get_news) )." của ".$data['total'];
		$this->data['type'] = $type;
		$this->data['degree'] = $this->config->item('job_degree');
		$this->data['job_experience'] = $this->config->item('job_experience');
		$this->data['job_room'] = $this->config->item('job_room');
		$this->data['job_form'] = $this->config->item('job_form');
		$this->data['job_wage'] = $this->config->item('job_wage');
		$this->data['cates'] = $this->home_model->get_cate_job_select(SERVICE_JOB);
		$this->data['left_room'] = $this->home_model->cate_room($num_type);

        // thong ke
        $this->data['jobtop'] = $this->home_model->job_statistic($cate_code , $num_type , 0 , $this->number_statistic);
        $this->header ="header-job";
		
		$this->load->view($this->header , $this->data);
		$this->load->view('left_job' , $this->data);
        $this->load->view('list_job' , $this->data);
        $this->load->view('right_job' , $this->data);
		$this->load->view('footer_contact' , $this->data);
	}
    //hien thi tin tuc cong viec theo id
	function detail_job($id = 0)
	{
	    $id = (int)$id;
        $this->home_model->job_update_view($id);
	    //$this->output->cache($this->timecate);
		$service_id = SERVICE_JOB;
		$item = $this->home_model->detail_job($id);
		if(!$item) redirect('viec-lam.html');
		$num_type =  $item['job_type'];
		$type = ($num_type == JOB_TYPE_JOB ? 'cho-ung-vien' : 'cho-nha-tuyen-dung');
		
		$this->cates = $this->home_model->get_cate_job($num_type);
		
		$this->data['title'] = $item['job_title'].' - Việc làm';
		$this->data['description'] =
            'Thông tin đầy đủ nhất về việc làm trong ngành thiết kế, quảng cáo và nghệ thuật.';
		$this->data['keywords'] =
            'Noithat: Thietkenoithat, Thietke, tubep, Noithat, phong ngu, Thiet ke kien truc, Noithat, vanphong, Thietke, kientruc, Thietke nha o, Thietke, khachsan, Thietke nhahang, Quanly duan, Tu van, Nha thau, Sofa, Chieu sang, Den chum,Thiet ke quang cao
            Thiet ke do hoa, Thiet le logo, Thiet ke thuong hieu, Thiet ke bao bi, Thiet ke slogan, Thiet ke in an, Thiet ke poster, Nha in, Quang cao, Truyen thong, Su kien, Media, Truyen hinh, Bao chi, Vat lieu xay dung
            Vat lieu noi that, Cua hang noi that, Thiet bi ve sinh, Thiet bi nha bep, Thu cong my nghe, Dao tao thiet ke, Studio, Nguoi mau, Nghe si,Hoa si, Thoi trang, Nghe thuat, Danh ba, Danh ba thiet ke
            Danh ba quang cao, Cuoc thi, Cuoc thi thiet ke, Cac cuoc thi, Giai thuong thiet ke, Tuyen dung, Viec lam thiet ke, Tuyen Kien truc su, Tuyen Designer, Nhan vien thiet ke, Thiet ke san pham, Tao dang cong nghiep, Thiet ke thoi trang';
		$this->data['cate_code'] = $item['job_cate_code'];
		$this->data['service_id'] = $service_id;
		$this->data['type'] = $type;
		$this->data['item'] = $item;
		$this->data['cate'] = $this->home_model->detail_cate($item['job_cate']);
		$this->data['left_room'] = $this->home_model->cate_room($num_type);
		$this->data['degree'] = $this->config->item('job_degree');
		$this->data['job_experience'] = $this->config->item('job_experience');
		$this->data['job_room'] = $this->config->item('job_room');
		$this->data['job_form'] = $this->config->item('job_form');
		$this->data['job_wage'] = $this->config->item('job_wage');
        
        $this->data['jobtop'] = $this->home_model->job_statistic($item['job_cate_code'] , $num_type , 0 , 8);
        
		//var_dump($this->data['cate']);
        $this->header ="header-job";
		$this->load->view($this->header , $this->data);
        $this->load->view('left_job' , $this->data);
		if($num_type == JOB_TYPE_JOB)
		{
			$this->load->view('detail_job' , $this->data);
		}
		else  $this->load->view('detail_seeker' , $this->data);
		$this->load->view('right_job' , $this->data);
		$this->load->view($this->footer , $this->data);
        
	}
    //hien thi cac su kien
	function event($day = -1 , $month = -1 , $year = -1 , $page = 1)
	{
	    //$this->output->cache($this->timecate);

	    $this->events = $this->home_model->list_event(0 , 3);
		//$this->jobs = $this->home_model->list_new_job(JOB_TYPE_JOB,0,8);
		$this->top_news = $this->home_model->top_news(0,$this->numtopnews*3);

		//$this->news_focus  =   $this->home_model->get_news_focus(0,9,1);
		//$this->quatang = $this->home_model->get_quatang();
        
        // v3
        $this->video = $this->home_model->list_news_cate('video',0,3);
        $this->images = $this->home_model->list_news_cate('nhiep-anh',0,3);
        $this->discovery = $this->home_model->list_news_discover('tieu-diem' , 0 , $this->numdiscovery*3);
        //chuyen de
        //$this->group = $this->home_model->list_group_home(0 ,$this->numgroup*3);
        /*---------------V4 --------------------*/
        $this->idear = get_idears(15);
        $this->onlydesigns = get_only_designs();
        //category kho y tuong
        $this->cate_idea = $this->home_model->getCateIdea();
        //du an
		$this->number_get_news = 10;
		$start = ((int)$page - 1)*$this->number_get_news;
		$start = $start > 0 ? $start : 0;
		$service_id = SERVICE_EVENT;
		
		$data = $this->home_model->list_home_event($day , $month , $year,$start , $this->number_get_news);
        
        $this->data['eventmonth'] = $this->home_model->list_event_month(($month == -1 ? date('m') : $month) , ($year == -1 ? date('Y') : $year));
        
		//echo get_url($ctmp , false);
		$config['base_url'] = base_url().(($year != -1 && $month != -1 && $day != -1) ? "cac-su-kien/{$day}-{$month}-{$year}_trang-" : "cac-su-kien_trang-");
		$config['total_rows'] = $data['total'];
		$config['per_page'] = $this->number_get_news;
		$config['key'] = '.html';
		$config['cur_page'] = $start;
		$config['num_links'] = 5;
		$config['first_link'] = '';
		$config['last_link'] = '';
		$config['next_link'] = '>>';
		$config['prev_link'] = '<<';
		$config['cur_tag_open'] = '<li><a id="current">';
		$config['cur_tag_close'] = '</a></li>';
		
		$this->my_paginationhome->initialize($config);
		
		$this->data['paging'] = $this->my_paginationhome->create_links();
		$this->data['items'] = sort_event($data['result']);
		$this->data['tops'] = $this->home_model->top_news(0 , 15 , 'date');
		$this->data['service_id'] = $service_id;
		$this->data['cate_code'] = 'cac-su-kien';
		$this->cates = get_menu(SERVICE_NEWS);
		
		$prefs['template'] = '

        {table_open}<table border="0" cellpadding="0" cellspacing="0" width="100%">{/table_open}

        {heading_row_start}<tr>{/heading_row_start}

        {heading_previous_cell}<th><a href="{previous_url}">&lt;&lt;</a></th>{/heading_previous_cell}
        {heading_title_cell}<th colspan="{colspan}"><strong>{heading}</strong></th>{/heading_title_cell}
        {heading_next_cell}<th><a href="{next_url}">&gt;&gt;</a></th>{/heading_next_cell}

        {heading_row_end}</tr>{/heading_row_end}

        {week_row_start}<tr>{/week_row_start}
        {week_day_cell}<td class="name-day">{week_day}</td>{/week_day_cell}
        {week_row_end}</tr>{/week_row_end}

        {cal_row_start}<tr>{/cal_row_start}
        {cal_cell_start}<td>{/cal_cell_start}

        {cal_cell_content}<a id="id{day}-{month}-{year}" href="javascript:alert(\'Ngày này không có sự kiện nào.\')" rel="'.base_url().'cac-su-kien/{day}-{month}-{year}/">{day}</a>{/cal_cell_content}
        {cal_cell_content_today}<div class="highlight"><a id="{day}-{month}-{year}" href="javascript:alert(\'Ngày này không có sự kiện nào.\')" rel="'.base_url().'cac-su-kien/{day}-{month}-{year}/">{day}</a></div>{/cal_cell_content_today}

        {cal_cell_no_content}<a id="id{day}-{month}-{year}" href="javascript:alert(\'Ngày này không có sự kiện nào.\')" rel="'.base_url().'cac-su-kien/{day}-{month}-{year}/">{day}</a>{/cal_cell_no_content}
        {cal_cell_no_content_today}<div class="highlight"><a  href="javascript:alert(\'Ngày này không có sự kiện nào.\')"id="id{day}-{month}-{year}" rel="'.base_url().'cac-su-kien/{day}-{month}-{year}/">{day}</a></div>{/cal_cell_no_content_today}

        {cal_cell_blank}<div class="blank">&nbsp;</div>{/cal_cell_blank}

        {cal_cell_end}</td>{/cal_cell_end}
        {cal_row_end}</tr>{/cal_row_end}

        {table_close}</table>{/table_close}
        ';
		$prefs['show_next_prev'] = TRUE;
		$prefs['next_prev_url'] = base_url().'cac-su-kien/';
		$this->load->library('calendar', $prefs);
		
		$this->data['calendar'] = $this->calendar->generate(($year == -1 ? date('Y') : $year ),($month == -1 ? date('m') : $month), $prefs);
		
        $this->data['title'] = 'Các sự kiện  - www.designs.vn';
		$this->data['description']    =
            'Các sự kiện thiết kế, quảng cáo và nghệ thuật tại Việt Nam và trên toàn Thế giới.';
		$this->data['keywords']       =
            'Noithat: Thietkenoithat, Thietke, tubep, Noithat, phong ngu, Thiet ke kien truc, Noithat, vanphong, Thietke, kientruc, Thietke nha o, Thietke, khachsan, Thietke nhahang, Quanly duan, Tu van, Nha thau, Sofa, Chieu sang, Den chum,Thiet ke quang cao
            Thiet ke do hoa, Thiet le logo, Thiet ke thuong hieu, Thiet ke bao bi, Thiet ke slogan, Thiet ke in an, Thiet ke poster, Nha in, Quang cao, Truyen thong, Su kien, Media, Truyen hinh, Bao chi, Vat lieu xay dung
            Vat lieu noi that, Cua hang noi that, Thiet bi ve sinh, Thiet bi nha bep, Thu cong my nghe, Dao tao thiet ke, Studio, Nguoi mau, Nghe si,Hoa si, Thoi trang, Nghe thuat, Danh ba, Danh ba thiet ke
            Danh ba quang cao, Cuoc thi, Cuoc thi thiet ke, Cac cuoc thi, Giai thuong thiet ke, Tuyen dung, Viec lam thiet ke, Tuyen Kien truc su, Tuyen Designer, Nhan vien thiet ke, Thiet ke san pham, Tao dang cong nghiep, Thiet ke thoi trang';
	
		$this->load->view($this->header,$this->data);
        $this->load->view('left_home',$this->data);
		$this->load->view('event',$this->data);
        $this->load->view('right_home',$this->data);
		$this->load->view($this->footer,$this->data);
	}

    //search form

	function search_news($key = '' , $page = 1)
	{
	    //$this->output->cache($this->timecate);
	    $this->events = $this->home_model->list_event(0 , 3);
		//$this->jobs = $this->home_model->list_new_job(JOB_TYPE_JOB,0,8);
		$this->top_news = $this->home_model->top_news(0,$this->numtopnews*3);

		//$this->news_focus  =   $this->home_model->get_news_focus(0,9,1);
		//$this->quatang = $this->home_model->get_quatang();
        
        // v3
        $this->video = $this->home_model->list_news_cate('video',0,3);
        $this->images = $this->home_model->list_news_cate('nhiep-anh',0,3);
        $this->discovery = $this->home_model->list_news_discover('tieu-diem' , 0 , $this->numdiscovery*3);
        //chuyen de
        $this->group = $this->home_model->list_group_home(0 ,$this->numgroup*3);
        /*---------------V4 --------------------*/
        $this->idear = get_idears(15);
        $this->onlydesigns = get_only_designs();
        //category kho y tuong
        $this->cate_idea = $this->home_model->getCateIdea();

		$key = mysql_escape_string($key);
		if($key == '') redirect();
		$page = (int)$page;
		$this->number_get_news = 10;
		$start = ((int)$page - 1)*$this->number_get_news;
		$start = $start > 0 ? $start : 0;
		$service_id = SERVICE_NEWS;
		
		$data = $this->home_model->search_news($key , $start , $this->number_get_news);
		
		//echo get_url($ctmp , false);
		$config['base_url'] = base_url().'tin-tuc/tim-kiem/'.$key.'_trang-';
		$config['total_rows'] = $data['total'];
		$config['per_page'] = $this->number_get_news;
		$config['key'] = '';
		$config['cur_page'] = $start;
		$config['num_links'] = 5;
		$config['first_link'] = '';
		$config['last_link'] = '';
		$config['next_link'] = '>>';
		$config['prev_link'] = '<<';
		$config['cur_tag_open'] = '<li><a id="current">';
		$config['cur_tag_close'] = '</a></li>';
		
		$this->my_paginationhome->initialize($config);
		
		$this->data['paging'] = $this->my_paginationhome->create_links();
		$this->data['items'] = $data['result'];
		$this->data['key'] = htmlspecialchars($key);
		//$this->data['tops'] = $this->home_model->top_news(0 , 15 , 'date');
		$this->data['service_id'] = $service_id;
		$this->data['cate_code'] = '';
		$this->cates = get_menu($service_id);
		
       	$this->data['title'] = 'Các kế quả liên quan tới: '.$this->data['key'];
		$this->data['description']    =
            'Danh bạ thiết kế, Cuộc thi thiết kế, Giải thưởng thiết kế, Việc làm thiết kế, Các sự kiện, Kiến trúc, Nội thất, Đồ họa, Quảng cáo, Hội họa, Nhiếp ảnh, Điện ảnh, Thời trang, Thiết kế sản phẩm.';
		$this->data['keywords']       =
            'Noithat: Thietkenoithat, Thietke, tubep, Noithat, phong ngu, Thiet ke kien truc, Noithat, vanphong, Thietke, kientruc, Thietke nha o, Thietke, khachsan, Thietke nhahang, Quanly duan, Tu van, Nha thau, Sofa, Chieu sang, Den chum,Thiet ke quang cao
            Thiet ke do hoa, Thiet le logo, Thiet ke thuong hieu, Thiet ke bao bi, Thiet ke slogan, Thiet ke in an, Thiet ke poster, Nha in, Quang cao, Truyen thong, Su kien, Media, Truyen hinh, Bao chi, Vat lieu xay dung
            Vat lieu noi that, Cua hang noi that, Thiet bi ve sinh, Thiet bi nha bep, Thu cong my nghe, Dao tao thiet ke, Studio, Nguoi mau, Nghe si,Hoa si, Thoi trang, Nghe thuat, Danh ba, Danh ba thiet ke
            Danh ba quang cao, Cuoc thi, Cuoc thi thiet ke, Cac cuoc thi, Giai thuong thiet ke, Tuyen dung, Viec lam thiet ke, Tuyen Kien truc su, Tuyen Designer, Nhan vien thiet ke, Thiet ke san pham, Tao dang cong nghiep, Thiet ke thoi trang';
	
		$this->load->view($this->header,$this->data);
		$this->load->view('left_home',$this->data);
        $this->load->view('search_news',$this->data);
        $this->load->view('right_home',$this->data);
		$this->load->view($this->footer,$this->data);
	}

    //tim kiem cua danh ba
	function contact_search($key = -1,$cate = -1 , $city = -1 , $field = -1 , $scale = -1 , $page = 1)
	{
	    //$this->output->cache($this->timecate);
		//$this->number_get_contact = 15;
		$service_id = SERVICE_CONTACT;
		$start = ((int)$page - 1)*$this->number_get_contact;
		$start = $start > 0 ? $start : 0;
		$this->cates = $this->home_model->get_cate_contact();
		
		$data = $this->home_model->search_contact($key,$cate ,$city, $field,$scale, $start , $this->number_get_contact);
		
		$config['base_url'] = base_url().'danh-ba-thiet-ke/tim-kiem/'.$key.'/'.$cate.'/'.$city.'/'.$field.'/'.$scale.'_trang-';
		$config['total_rows'] = $data['total'];
		$config['per_page'] = $this->number_get_contact;
		$config['key'] = '';
		$config['cur_page'] = $start;
		$config['num_links'] = 5;
		$config['first_link'] = '';
		$config['last_link'] = '';
		$config['next_link'] = '>>';
		$config['prev_link'] = '<<';
		$config['cur_tag_open'] = '<li><a id="current">';
		$config['cur_tag_close'] = '</a></li>';
		
		$this->my_paginationhome->initialize($config);
		
		$this->data['paging'] = $this->my_paginationhome->create_links();
		
		$this->data['items'] = $data['result'];
		$this->data['title'] = 'Các kết quả liên quan tới tìm kiếm trong Dạnh bạ thiết kế - www.designs.vn';
		$this->data['description'] =
            'Danh bạ các công ty thiết kế, quảng cáo, nhà cung cấp vật liệu xây dựng, nội thất ....';
		$this->data['keywords']    =
            'Noithat: Thietkenoithat, Thietke, tubep, Noithat, phong ngu, Thiet ke kien truc, Noithat, vanphong, Thietke, kientruc, Thietke nha o, Thietke, khachsan, Thietke nhahang, Quanly duan, Tu van, Nha thau, Sofa, Chieu sang, Den chum,Thiet ke quang cao
            Thiet ke do hoa, Thiet le logo, Thiet ke thuong hieu, Thiet ke bao bi, Thiet ke slogan, Thiet ke in an, Thiet ke poster, Nha in, Quang cao, Truyen thong, Su kien, Media, Truyen hinh, Bao chi, Vat lieu xay dung
            Vat lieu noi that, Cua hang noi that, Thiet bi ve sinh, Thiet bi nha bep, Thu cong my nghe, Dao tao thiet ke, Studio, Nguoi mau, Nghe si,Hoa si, Thoi trang, Nghe thuat, Danh ba, Danh ba thiet ke
            Danh ba quang cao, Cuoc thi, Cuoc thi thiet ke, Cac cuoc thi, Giai thuong thiet ke, Tuyen dung, Viec lam thiet ke, Tuyen Kien truc su, Tuyen Designer, Nhan vien thiet ke, Thiet ke san pham, Tao dang cong nghiep, Thiet ke thoi trang';
		$this->data['cate_code'] = $cate;
		$this->data['service_id'] = $service_id;
		$this->data['local'] = $this->home_model->get_city();
		$this->data['slocal'] = $city;
		$this->data['field'] = $field;
		$this->data['scale'] = $scale;
        $this->data['key'] = ($key == -1 ? 'Tìm trong danh bạ' : $key);
		$this->header = 'header-contact.php';
		$this->load->view($this->header , $this->data);
		$this->load->view('left_contact' , $this->data);
        $this->load->view('contact_list' , $this->data);
        $this->load->view('right_contact' , $this->data);
		$this->load->view($this->footer , $this->data);
	}
	//search theo  cong viec cua cong viec
	function search_job($type = 1 , $job_location = -1 , $job_cate = -1 , $job_degree = -1 , $job_room = -1 , $job_wage = -1 , $job_experience = -1 , $keywords = -1, $page = 1)
	{
	    //$this->output->cache($this->timecate);
        $this->data_footer = $this->home_model->get_footer(1);
        $this->tags = $this->home_model->get_footer(2);
		//$this->number_get_news = 30;
		$service_id = SERVICE_JOB;
		$num_type =($type == 'cho-ung-vien' ? JOB_TYPE_JOB : JOB_TYPE_SEEKER);
		
		if(isset($_POST['submit']))
		{
			$data = $_POST['data'];
			$data['job_type'] = $num_type;
			$data['job_date_create'] = time();
			$tmp = explode('|',$_POST['cate']);
			$data['job_cate'] = @$tmp[0];
			$data['job_cate_code'] = @$tmp[1];
			if($this->home_model->add_job($data)) $this->msg[] = 'Bạn đã thêm mới hồ sơ thành công.Chúng tôi sẽ xem xét hồ sơ của bạn sớm nhất có thể';
		}
		$start = ((int)$page - 1)*$this->number_get_news;
		$start = $start > 0 ? $start : 0;
		$this->cates = $this->home_model->get_cate_job($num_type );
		$data = $this->home_model->search_job($num_type , $job_location, $job_cate , $job_degree , $job_room , $job_wage, $job_experience,$keywords, $start , $this->number_get_news);
		
		$config['base_url'] = base_url().'viec-lam/tim-kiem/'.$type.'/'.$job_location.'/'.$job_cate.'/'.$job_degree.'/'.$job_room.'/'.$job_wage.'/'.$job_experience.'/'.$keywords.'/0';
		$config['total_rows'] = $data['total'];
		$config['per_page'] = $this->number_get_news;
		$config['key'] = '.html';
		$config['cur_page'] = $start;
		$config['num_links'] = 5;
		$config['first_link'] = '';
		$config['last_link'] = '';
		$config['next_link'] = '>>';
		$config['prev_link'] = '<<';
		$config['cur_tag_open'] = '<li><a id="current">';
		$config['cur_tag_close'] = '</a></li>';
		
		$this->my_paginationhome->initialize($config);
		
		$this->data['paging'] = $this->my_paginationhome->create_links();
		
		
		$this->data['title'] = 'Các kết quả liên quan tới tìm kiếm trong Việc làm - www.designs.vn';
		$this->data['description'] =
            'Thông tin đầy đủ nhất về việc làm trong ngành thiết kế, quảng cáo và nghệ thuật.';
		$this->data['keywords']    =
            'Noithat: Thietkenoithat, Thietke, tubep, Noithat, phong ngu, Thiet ke kien truc, Noithat, vanphong, Thietke, kientruc, Thietke nha o, Thietke, khachsan, Thietke nhahang, Quanly duan, Tu van, Nha thau, Sofa, Chieu sang, Den chum,Thiet ke quang cao
            Thiet ke do hoa, Thiet le logo, Thiet ke thuong hieu, Thiet ke bao bi, Thiet ke slogan, Thiet ke in an, Thiet ke poster, Nha in, Quang cao, Truyen thong, Su kien, Media, Truyen hinh, Bao chi, Vat lieu xay dung
            Vat lieu noi that, Cua hang noi that, Thiet bi ve sinh, Thiet bi nha bep, Thu cong my nghe, Dao tao thiet ke, Studio, Nguoi mau, Nghe si,Hoa si, Thoi trang, Nghe thuat, Danh ba, Danh ba thiet ke
            Danh ba quang cao, Cuoc thi, Cuoc thi thiet ke, Cac cuoc thi, Giai thuong thiet ke, Tuyen dung, Viec lam thiet ke, Tuyen Kien truc su, Tuyen Designer, Nhan vien thiet ke, Thiet ke san pham, Tao dang cong nghiep, Thiet ke thoi trang';
		$this->data['cate_code'] = '';
		$this->data['service_id'] = $service_id;
		$this->data['local'] = $this->home_model->get_city();
		$this->data['items'] = $data['result'];
		$this->data['str'] = "Hiển thị ".($data['total'] > 0 ? ($start +1) : 0)." tới ".(($start+$this->number_get_news) > $data['total'] ? $data['total'] : ($start+$this->number_get_news) )." của ".$data['total'];
		$this->data['type'] = $type;
		$this->data['degree'] = $this->config->item('job_degree');
		$this->data['job_experience'] = $this->config->item('job_experience');
		$this->data['job_room'] = $this->config->item('job_room');
		$this->data['job_form'] = $this->config->item('job_form');
		$this->data['job_wage'] = $this->config->item('job_wage');
		$this->data['cates'] = $this->home_model->get_cate_job_select(SERVICE_JOB);
		$this->data['slocation'] = $job_location;
		$this->data['sjob_cate'] = $job_cate;
		$this->data['sjob_degree'] = $job_degree;
		$this->data['sjob_room'] = $job_room;
		$this->data['sjob_wage'] = $job_wage;
		$this->data['sjob_experience'] = $job_experience;
		$this->data['left_room'] = $this->home_model->cate_room($num_type);
        $this->data['key'] = ($keywords != -1 ? $keywords : '');
        $this->data['textsearch'] = $num_type == JOB_TYPE_JOB ? 'Tìm trong việc làm' : 'Tìm trong hồ sơ';
        $this->data['fsearch'] = 'searchjob('.$num_type.')';
		$this->header = 'header-job.php';
		$this->load->view($this->header , $this->data);
		$this->load->view('left_job' , $this->data);
        $this->load->view('list_job' , $this->data);
        $this->load->view('right_job' , $this->data);
		$this->load->view($this->footer , $this->data);
	}
	/*index
	function simple($service_id = 7)
	{
		$detail = $this->home_model->simple($service_id);
        $this->data_footer = $this->home_model->get_footer(1);
        $this->tags = $this->home_model->get_footer(2);
		if($detail)
		{
			$this->data['title'] = $detail['title'];
			$this->data['description'] = $detail['extract'];
			$this->data['keywords'] = $detail['extract'];
			$this->data['item'] = $detail;
			$this->cates = get_menu(SERVICE_NEWS);
			$this->data['cate_code'] = $detail['cate_code'];
			$this->data['service_id'] = $service_id;
			$this->load->view($this->header,$this->data);
			$this->load->view('cate_single',$this->data);
			$this->load->view($this->footer,$this->data);
			
		}
		else redirect();
	}
	// v3
    /**
    * trả lời câu hỏi
    * */
    function check_poll($idcate)
    {
        $this->load->library('input');
        if($this->poll_model->check_ip($idcate,$this->input->ip_address()) > 0)
        echo 'ERROR';
        else echo 'OK';
    }
    function answer($cat_id,$id){
        if(isset($_POST['submit'])){
            $xacnhan = $_POST['xacnhan'];
            if($cat_id > 0 AND $id > 0 and $xacnhan==2 ){
                //update vote 
                $this->load->library('input');
                $this->poll_model->update_answer($id,$cat_id);
                $this->poll_model->add_poll_log(array('id_answer'=>$cat_id,'ip'=>$this->input->ip_address()));
                redirect(base_url().'home/poll_result/'.$cat_id);
            }
        }
        $this->data['title'] = "Bình chọn trên www.designs.vn";
        $this->load->view('poll_answer', $this->data);
    }
    /**
   * hien thi danh sach ket qua
   * */
   function poll_result($poll_id){
       $this->data['title'] = "Kết quả của bình chọn trên www.designs.vn";
       $this->data['result'] = $this->poll_model->get_answer_poll($poll_id);
       $this->data['cat_poll'] = $this->poll_model->get_cate_poll($poll_id);
       $this->load->view('poll_result', $this->data);
   }
   //dang cap nhat
   function group_news($code = 0, $page = 1)
	{
	    //$this->output->cache($this->timecate);
	    $this->events = $this->home_model->list_event(0 , 3);
		//$this->jobs = $this->home_model->list_new_job(JOB_TYPE_JOB,0,8);
		$this->top_news = $this->home_model->top_news(0,$this->numtopnews*3);

		//$this->news_focus  =   $this->home_model->get_news_focus(0,9,1);
		$this->quatang = $this->home_model->get_quatang(); 
        
        // v3
        $this->video = $this->home_model->list_news_cate('video',0,3);
        $this->images = $this->home_model->list_news_cate('nhiep-anh',0,3);
        $this->discovery = $this->home_model->list_news_discover('tieu-diem' , 0 , $this->numdiscovery*3);
        //chuyen de
        //$this->group = $this->home_model->list_group_home(0 ,$this->numgroup*3);
        /*---------------V4 --------------------*/
        $this->idear = get_idears(15);
        $this->onlydesigns = get_only_designs();
        //category kho y tuong
        $this->cate_idea = $this->home_model->getCateIdea();

	    $service_id = SERVICE_NEWS;
		$prefix = 'chuyen-de/';
		
		$start = ((int)$page - 1)*$this->number_get_news;
		$start = $start > 0 ? $start : 0;

        $data = $this->home_model->list_news_group($code , $start , $this->number_get_news);
		$this->data['newsGroup'] = $this->home_model->list_news_group($code , $start , $this->number_get_news);
        //echo '<pre>'; var_dump($data); echo '</pre>';die;

		//echo get_url($ctmp , false);
		$config['base_url'] = base_url().$prefix.$code.'_trang-';
		$config['total_rows'] = $data['total'];
		$config['per_page'] = $this->number_get_news;
		$config['key'] = '.html';
		$config['cur_page'] = $start;
		$config['num_links'] = 5;
		$config['first_link'] = '';
		$config['last_link'] = '';
		$config['next_link'] = '>>';
		$config['prev_link'] = '<<';
		$config['cur_tag_open'] = '<li><a id="current">';
		$config['cur_tag_close'] = '</a></li>';
		
		$this->my_paginationhome->initialize($config);
		
		$this->data['paging'] = $this->my_paginationhome->create_links();
		$this->data['items'] = $data['result'];
		$this->data['tops'] = $this->home_model->top_news(0 , 15 , 'date');
		$this->data['service_id'] = $service_id;
		$this->data['cate_code'] = $code;
        $this->data['group'] = array($code);
		$this->cates = get_menu(SERVICE_NEWS);
		
		$this->load->view($this->header,$this->data);
        $this->load->view('left_home',$this->data);
		$this->load->view('news_group',$this->data);
        $this->load->view('right_home',$this->data);
		$this->load->view($this->footer,$this->data);
	}

    //only designs,thu vien
    function group($type = 0 , $page = 1)
    {
        //$this->output->cache($this->timecate);
        $this->data_footer = $this->home_model->get_footer(1);
        $this->tags = $this->home_model->get_footer(2);
        $this->events = $this->home_model->list_event(0 , 3);
		//$this->jobs = $this->home_model->list_new_job(JOB_TYPE_JOB,0,8);
		$this->top_news = $this->home_model->top_news(0,$this->numtopnews*3);
		
		$this->news_focus  =   $this->home_model->get_news_focus(0,9,1);
		$this->quatang = $this->home_model->get_quatang(); 
        
        // v3
        $this->video = $this->home_model->list_news_cate('video',0,3);
        $this->images = $this->home_model->list_news_cate('nhiep-anh',0,3);
        $this->discovery = $this->home_model->list_news_discover('tieu-diem' , 0 , $this->numdiscovery*3);
        //chuyen de
        $this->group = $this->home_model->list_group_home(0 ,$this->numgroup*3);
        /*---------------V4 --------------------*/
        $this->idear = get_idears(15);
        $this->onlydesigns = get_only_designs();
        $this->catecontact = $this->home_model->get_cate_contact();
        
        $service_id = SERVICE_NEWS;
		$prefix = ($type == 1 ? 'only-designs' : ($type == 2 ? 'kho-y-tuong' : 'chuyen-de'));

		$start = ((int)$page - 1)*$this->number_get_news;
		$start = $start > 0 ? $start : 0;

		$data = $this->home_model->list_group($start , $this->number_get_news, $type);
		$config['base_url'] = base_url().$prefix.'_trang-';
		$config['total_rows'] = $data['total'];
		$config['per_page'] = $this->number_get_news;
		$config['key'] = '.html';
		$config['cur_page'] = $start;
		$config['num_links'] = 5;
		$config['first_link'] = '';
		$config['last_link'] = '';
		$config['next_link'] = '>>';
		$config['prev_link'] = '<<';
		$config['cur_tag_open'] = '<li><a id="current">';
		$config['cur_tag_close'] = '</a></li>';
		
		$this->my_paginationhome->initialize($config);
		
		$this->data['paging'] = $this->my_paginationhome->create_links();
		$this->data['items'] = $data['result'];
		$this->data['tops'] = $this->home_model->top_news(0 , 15 , 'date');
		$this->data['service_id'] = $service_id;
		$this->data['cate_code'] = '';
        $this->data['group'] = array();
        $this->data['gtype'] = $type;
		$this->cates = get_menu(SERVICE_NEWS);
		
		$this->load->view($this->header,$this->data);
        $this->load->view('left_home',$this->data);
		$this->load->view('group',$this->data);
        $this->load->view('right_home',$this->data);
		$this->load->view($this->footer,$this->data);
    }
    //dang nhap
    function job_log($type = 1,$cate_code=-1 , $page = 1)
    {
        //$type = JOB_TYPE_JOB;
        $this->load->helper('user_helper');
        $this->load->model('user_model');
        $this->data_footer = $this->home_model->get_footer(1);
        $this->tags = $this->home_model->get_footer(2);
        $service = 3;
        if (!check_login_user ()) redirect(link_user_view());
        	$service_id = (int)$service;
		$num_type = $type;
        $type = ($type == JOB_TYPE_JOB ? 'cho-ung-vien' : 'cho-nha-tuyen-dung');
		
		$start = ((int)$page - 1)*$this->number_get_news;
		$start = $start > 0 ? $start : 0;
		$this->cates = $this->home_model->get_cate_job($num_type);
		$data = $this->user_model->list_job_logs(info_from_session_user(0) , $num_type , $start , 20);
        $data2 = $this->user_model->list_job(info_from_session_user(0) , ($num_type == JOB_TYPE_JOB ? JOB_TYPE_SEEKER : JOB_TYPE_JOB) , $start , 20);
		
		$this->data['title'] = 'Việc làm - www.designs.vn';
		$this->data['description'] =
            'Thông tin đầy đủ nhất về việc làm trong ngành thiết kế, quảng cáo và nghệ thuật ';
		$this->data['keywords']   =
            'Noithat: Thietkenoithat, Thietke, tubep, Noithat, phong ngu, Thiet ke kien truc, Noithat, vanphong, Thietke, kientruc, Thietke nha o, Thietke, khachsan, Thietke nhahang, Quanly duan, Tu van, Nha thau, Sofa, Chieu sang, Den chum,Thiet ke quang cao
            Thiet ke do hoa, Thiet le logo, Thiet ke thuong hieu, Thiet ke bao bi, Thiet ke slogan, Thiet ke in an, Thiet ke poster, Nha in, Quang cao, Truyen thong, Su kien, Media, Truyen hinh, Bao chi, Vat lieu xay dung
            Vat lieu noi that, Cua hang noi that, Thiet bi ve sinh, Thiet bi nha bep, Thu cong my nghe, Dao tao thiet ke, Studio, Nguoi mau, Nghe si,Hoa si, Thoi trang, Nghe thuat, Danh ba, Danh ba thiet ke
            Danh ba quang cao, Cuoc thi, Cuoc thi thiet ke, Cac cuoc thi, Giai thuong thiet ke, Tuyen dung, Viec lam thiet ke, Tuyen Kien truc su, Tuyen Designer, Nhan vien thiet ke, Thiet ke san pham, Tao dang cong nghiep, Thiet ke thoi trang';

		$this->data['cate_code'] = $type;
		$this->data['service_id'] = $service_id;
		$this->data['local'] = $this->home_model->get_city();
		$this->data['items'] = $data['result'];
        $this->data['items2'] = $data2['result'];
		$this->data['str'] = "Hiển thị ".($data['total'] > 0 ? ($start +1) : 0)." tới ".(($start+$this->number_get_news) > $data['total'] ? $data['total'] : ($start+$this->number_get_news) )." của ".$data['total'];
		$this->data['type'] = $type;
		$this->data['degree'] = $this->config->item('job_degree');
		$this->data['job_experience'] = $this->config->item('job_experience');
		$this->data['job_room'] = $this->config->item('job_room');
		$this->data['job_form'] = $this->config->item('job_form');
		$this->data['job_wage'] = $this->config->item('job_wage');
		$this->data['cates'] = $this->home_model->get_cate_job_select(SERVICE_JOB);
		$this->data['left_room'] = $this->home_model->cate_room($num_type);
        $this->data['num_type'] = $num_type;
        $this->data['job_log'] = 1;
        
        // thong ke
        $this->data['jobtop'] = $this->home_model->job_statistic($cate_code , $num_type , 0 , $this->number_statistic);
		$this->header = 'header-job';
		$this->load->view($this->header , $this->data);
		$this->load->view('left_job' , $this->data);
        $this->load->view('job_logs' , $this->data);
        $this->load->view('right_job' , $this->data);
		$this->load->view($this->footer , $this->data);
    }
    /*-------------------------- V4 --------------------------
    Fashion contest
    */
    function undercontrucstion($cate = '')
    {
        $this->events = $this->home_model->list_event(0 , 3);
		//$this->jobs = $this->home_model->list_new_job(JOB_TYPE_JOB,0,8);
		$this->top_news = $this->home_model->top_news(0,$this->numtopnews*3);
		$this->news_focus  =   $this->home_model->get_news_focus(0,9,1);
		$this->quatang = $this->home_model->get_quatang(); 
        
        // v3
        $this->video = $this->home_model->list_news_cate('video',0,3);
        $this->images = $this->home_model->list_news_cate('nhiep-anh',0,3);
        $this->discovery = $this->home_model->list_news_discover('tieu-diem' , 0 , $this->numdiscovery*3);
        //chuyen de
        $this->group = $this->home_model->list_group_home(0 ,$this->numgroup*3);
        /*---------------V4 --------------------*/
        $this->idear = get_idears(15);
        $this->onlydesigns = get_only_designs();
        $this->catecontact = $this->home_model->get_cate_contact();
        
        $img = '';
        switch($cate)
        {
            case 'showroom' : $img = base_url().'public/temp/img/SHOROOM.png';
            break;
            case 'awards' : $img = base_url().'public/temp/img/GIAI-THUONG.png';
            break;
            case 'fashion-contest' : $img = base_url().'public/temp/img/FASHION.png';
            break;
            case 'foto-contest' : $img = base_url().'public/temp/img/PHOTO.png';
            break;
        }
        $service_id = SERVICE_NEWS;
	   
		$this->data['img'] = $img;
		$this->data['tops'] = $this->home_model->top_news(0 , 15 , 'date');
		$this->data['service_id'] = $service_id;
		$this->data['cate_code'] = '';
        $this->data['group'] = array();
		$this->cates = get_menu(SERVICE_NEWS);
		
		$this->load->view($this->header,$this->data);
        $this->load->view('left_home',$this->data);
		$this->load->view('undercontrucstion',$this->data);
        $this->load->view('right_home',$this->data);
		$this->load->view($this->footer,$this->data);
    }

    //rong
    function tag($k = '')
    {
        $k = trim($k);
        $data = array();
        if($k)
        {
            $d = $this->home_model->listtagu($k);
            if($d)
            {
                foreach($d as $val)
                {
                    $data[] = $val['username'];
                }
            }
        }
        echo json_encode($data);
    }
}

